Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel, how to manually install package without composer

Wanted to install Laravel-Excel (Maatwebsite) package manually without composer, but I dont know how.

Why? Because I have a laravel project in a free hosting server setup by other guy, and I can only access using Filezilla to edit/download/upload the codes.

If only Filezilla allow a command prompt that could use "composer update", then it will be easier.

like image 500
begineeeerrrr Avatar asked Aug 08 '17 10:08

begineeeerrrr


People also ask

Can I install Laravel without composer?

You cannot install laravel local without composer in your project.

Can I install composer without PHP?

You can place the Composer PHAR anywhere you wish. If you put it in a directory that is part of your PATH , you can access it globally. On Unix systems you can even make it executable and invoke it without directly using the php interpreter.

Why does Laravel need composer?

In Laravel, the composer is a tool that includes all the dependencies and libraries. It helps the user to develop a project with respect to the mentioned framework. Third-party libraries can be installed easily using composer. Composer is used to managing its dependencies and the dependencies are noted in composer.


1 Answers

I got solution! I cant use composer on my company because of secure network. But i can download zip form github and install it manual. The below is my example for HTMLPurifier:

  1. download and extract library mews/purifier to vendor directory https://github.com/mewebstudio/Purifier
  2. add below line in vendor/composer/autoload_psr4.php

This sentence will load all of file from vendor/mews/purifier/src and autoload in namespace Mews\Purifier\

'Mews\\Purifier\\' => array($vendorDir . '/mews/purifier/src'),

Sometime you need add library into autoload_namespaces.php intead of, please read in https://getcomposer.org/doc/04-schema.md#autoload

You got Mews\Purifier\Facades\Purifier not found if public config before finish step 3

$ php artisan vendor:publish --provider="Mews\Purifier\PurifierServiceProvider"

  1. add below json in vendor/composer/installed.json

This for composer history, providers and aliases will be load in config/app/php for register new provider

{
    "name": "mews/purifier",
    "version": "v2.0.12",
    "type": "library",
    "extra": {
        "laravel": {
            "providers": [
                "Mews\\Purifier\\PurifierServiceProvider"
            ],
            "aliases": {
                "Purifier": "Mews\\Purifier\\Facades\\Purifier"
            }
        }
    },
    "autoload": {
        "psr-4": {
            "Mews\\Purifier\\": "src/"
        }
    }
},

Now you run this config, then vendor/mews/purifier/config will be move to config folder

$ php artisan vendor:publish --provider="Mews\Purifier\PurifierServiceProvider"

like image 54
Quockhanh Pham Avatar answered Sep 20 '22 11:09

Quockhanh Pham