Laravel, how to manually install package without composer

31,913

Solution 1

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"

Solution 2

  1. Add the package to the vendor folder. You can upload it using filezilla
  2. Add a reference in \vendor\composer\autoload_namespaces.php
  3. Add a reference in \vendor\composer\autoload_psr4.php

Source laravel.io

Solution 3

it's easy to do it by following this download the package and set the files in app folder

YourProject/app/Laravel-Excel/

and then add the path to composer.json in autoload

"autoload": {
    ...
    "classmap": [
        "database/seeds",
        "database/factories"
        "app/Laravel-Excel"
    ],
    ...
},

Run the composer dump-autoload

the solution refs to this question referance answer

Solution 4

download the package locally and then upload the package folder (found under vendor) along with the updated composer.json

Share:
31,913

Related videos on Youtube

begineeeerrrr
Author by

begineeeerrrr

Updated on July 09, 2022

Comments

  • begineeeerrrr
    begineeeerrrr almost 2 years

    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.

  • begineeeerrrr
    begineeeerrrr over 6 years
    I tried your method yesterday. Download the package, take the maatwebsite folder in vendor, edit config/app, edit composer.json, but it produce an error
  • begineeeerrrr
    begineeeerrrr over 6 years
    Class 'Maatwebsite\Excel\ExcelServiceProvider' not found. I already put Maatwebsite\Excel\ExcelServiceProvider::class, at providers in config/app and 'Excel' => Maatwebsite\Excel\Facades\Excel::class, at aliases. And I already uploaded the vendor file
  • Ali
    Ali over 6 years
    are all the packages currently installed working properly or they're all throwing the same error?
  • begineeeerrrr
    begineeeerrrr over 6 years
    The laravel project is everything inside the server and i dont have it locally. And i am not allowed download everything in the server and reupload the whole thing, how to do it manually?
  • begineeeerrrr
    begineeeerrrr over 6 years
    all the other package that currently installed is working perfectly, just this Laravel/Excel package are not
  • connormcwood
    connormcwood over 6 years
    @begineeeerrrr If you don't have it locally you could create a new laravel project and composer install the package you want. Find it in the vendor file and upload it to the site. Edit the required live config/app so that its links to its ServiceProvider and Facades and then reupload that. If you still get an error then a composer dumpautoload is required. You should, if you can, have the whole project locally and work using XAMPP or something similar using a vhost. Much better productivity.
  • Ali
    Ali over 6 years
    I think you need to run compose dump-autoload on your local machine and re-upload the entire vendor folder
  • begineeeerrrr
    begineeeerrrr over 6 years
    Produces error Class 'Maatwebsite\Excel\ExcelServiceProvider' not found, done exactly what you told. Here what I did, I make a new laravel project file, install Laravel/Excel (Maatwebsite) package, edit config/app, composer publish. Okay so far locally done. Now I upload the vendor(maatwebsite), edit config/app, edit composer.json, upload excel.php into config\
  • begineeeerrrr
    begineeeerrrr over 6 years
    Produces error Class 'Maatwebsite\Excel\ExcelServiceProvider' not found, done exactly what you told. Here what I did, I make a new laravel project file, install Laravel/Excel (Maatwebsite) package, edit config/app, composer publish. Okay so far locally done. Now I upload the vendor(maatwebsite), edit config/app, edit composer.json, upload excel.php into config\
  • abbood
    abbood over 6 years
    Hey Ali are you in the Beirut area?
  • saber tabatabaee yazdi
    saber tabatabaee yazdi almost 5 years
    no need to run php artisan vendor:publish in laravel?

Related