Altering the code of a Laravel vendor package

If you want to make some small changes in a vendor package and you don't want to fork it on GitHub, here is the instruction what you should do:
1. For example, you know the name of the package, it is, for example, leroy-merlin-br/larasniffer. Search it's repository in GitHub.
2. Create a directory called 'workbench' under the Laravel's root directory.
3. Create a dir with vendor name, for example, leroy-merlin-br, open it: mkdir leroy-merlin-br && cd  leroy-merlin-br
4. Clone a GitHub repo of that project into that folder, you will get something like /workbench/leroy-merlin-br/larasniffer: git clone https://github.com/leroy-merlin-br/larasniffer.git
5. Run composer update under that directory:

cd larasniffer
php -r "readfile('https://getcomposer.org/installer');" | php
php ./composer.phar update

6. Go to Laravel's root directory and run php artisan dump-autoload:

cd .. && cd .. && cd .. 
php artisan dump-autoload

You should get an additional string, something like:

Generating optimized class loader
Running for workbench [leroy-merlin-br/larasniffer]...

7. Go to app/config/app.php settings file and add appropriate provider name of your project (it should be mentioned in the instalation instructions of the package you are clonning):

    'providers' => array(
         ...
        'LeroyMerlin\LaraSniffer\ServiceProvider',
    ),

That's it, now you can modify the package as you want and use it in your project. You can pull the updates of the package from the GitHub repo and merge your changes with them, and you can even help the package's maintaner to develop his module.

Good luck!

Usefull links:
https://laracasts.com/discuss/channels/general-discussion/how-to-contrib...
https://laracasts.com/discuss/channels/general-discussion/customizing-a-...

Comments

Add new comment