How to Install Laravel Without Using Composer

Can I Install Laravel without using Composer?

If you really wanted to, you could do all the work that Composer does manually, but you definitely should not. Installing Composer is easy, it's just a matter of getting the composer.phar file and running commands on it.

You do not need to run Composer on your server as well as locally, once you run composer install or composer update your project will have all its dependencies available and you can just upload it straight to your server.

Install Laravel without Composer

I guess one way would be to run composer on another machine(maybe at home). Then just take all the files that composer downloads and move it to your work machine.

Installing it manually is a lot of work. You have to do all the stuff that composer does in the background effectively. Following all the dependencies will be super hard.

How do I install Composer PHP packages without Composer?

The composer.json file lists the dependencies. In your example:

"require": {
"php": ">=5.5.0",
"guzzlehttp/guzzle": "^6.0",
"psr/http-message": "^1.0",
"psr/log": "^1.0"
},

You must then find the corresponding packages in the packagist site. Repeat the same process for each dependency: find additional dependencies in their corresponding composer.json files and search again.

When you finally have a complete list of the required packages, you only need to install them all one by one. For the most part, it's just a matter of dropping the files somewhere in your project directory. But you must also ensure that PHP can find the needed classes. Since you aren't using Composer's auto-loader, you need to add them to your own custom autoloader. You can figure out the information from the respective composer.json files, e.g.:

"autoload": {
"psr-4": { "Coinbase\\Wallet\\": "src/" }
},

If you don't use a class auto-loader you'll need to figure out the individual require_once statements. You'll probably need a lot of trial and error because most library authors won't care documenting that.

Also, and just in case there's confusion about this:

  • Composer has an official GUI installer for Windows and a copy and paste command-line installation procedure for all platforms.
  • Composer can be run locally and its output just uploaded elsewhere. You don't need SSH in your shared hosting.
  • The command needed to install a library can be copied and pasted from the package web site—even if the package maintainer didn't care to document it, packagist.org generates it by default.

Composer is not perfect and it doesn't suit all use cases but, when it comes to installing a library that relies on it, it's undoubtedly the best alternative and it's a fairly decent one.


I've checked other answers that came after mine. They mostly fall in two categories:

  1. Install a library and write a custom download script with it
  2. Use an online web based interface for Composer

Unless I'm missing something, none of them address the complaints expressed by the OP:

  • Learning curve
  • Use of third-party software
  • Possibility to develop right on the server (using SSH, I presume)
  • Potentially deep dependency tree

how to use Stripe in laravel without using composer?

You do not need the Composer in your Hosting-Environment, If you have it in your Local-Environment then you will have the files already installed on your server. You could try Homestead what is already a pre-configured local-development environment for Laravel.

Composer is only a dependency-management-system, what makes you really easier to use open-source-code from other third party providers like the STRIPE-SDK.

But you can also use Stripes RAW REST-API's without the SDK, but it would be much more work - you can for example extract the needed parameters from the curl-example of stripe, but also if you use this direct way It would be easier to use a Curl-Wrapper-Library like Guzzle.

You should really have a deeper look into the composer, because if you want to use & contribute with some community-projects you need composer.


BTW: when you install laravel from scratch, then you still use the composer, as you see here.

Laravel install package without composer

you need to have ssh access to server and then just run this :

composer require PACKAGE_NAME

Laravel Sail Paradox - There are any way to install without php and composer installed?

edit

I was listening to the laravel news podcast yesterday and the people from Laravel created a solution for this problem. They now have a section with a command that spins up a php container to install php dependencies through a container first and move them to your host computer.

docker run --rm \
-u "$(id -u):$(id -g)" \
-v $(pwd):/var/www/html \
-w /var/www/html \
laravelsail/php81-composer:latest \
composer install --ignore-platform-reqs


As Sail gives you the option to manage the container from the host through Artisan, then no.

If you don't mind to give up the ability to use Sail in this way and just want to set up a dockerized environment for Laravel, then yes. You can make a container for php in which you copy your project and through volumes maps to the host. You can enter a container (as if using ssh) through docker-compose exec <service> <command>, in the repo I linked, the php Dockerfile uses Alpine as the linux distro, which comes with the ash (instead of bash) shell. Because of his you can run

docker-compose exec php ash

to enter the container and run commands inside it.

How to use Laravel libraries in Laravel project without composer

You can use the autoload mapping in order to adchieve that. Just create a folder with the file/files that you want to use. For example:

YourProject/app/MyClasses/

And store the files right there. Then you just have to use the composer classmap: Edit the composer.json file indicating the path to your classes:

"autoload": {
...
"classmap": [
"database/seeds",
"database/factories"
"app/MyClasses"
],
...
},

Run the composer dump-autoload command and you'll be ready to go.



Related Topics



Leave a reply



Submit