I am developing a library for Laravel which contains a service provider. I have added this library to another project\'s composer.json
file.
The compo
It looks like you're simply not including your ServiceProvider. Put this in your root project's composer.json
:
{
"autoload": {
"psr-4": {
"App\\": "app/",
"MyName\\MyProject\\": "../relative/path/to/serviceprovider/"
}
}
}
Run This
composer install --ignore-platform-reqs
When using composer install
or composer update
you can use --no-scripts
option to skips execution of scripts defined in composer.json.
e. g.: composer update --no-scripts
.
Source: https://getcomposer.org/doc/03-cli.md#install
This issue has finally been resolved as of laravel/framework:v5.2.25
and laravel/laravel:v5.2.27
, and backported to laravel/framework:v5.1.33
and laravel/laravel:v5.1.33
.
This fix includes a change to the Laravel application (laravel/laravel
), in addition to the Laravel Framework (laravel/framework
). To implement, you will need to:
1) Update the scripts
section of your composer.json
file to match that in the laravel/laravel package. Specifically:
pre-update-cmd
sectionpost-install-cmd
section, replace "php artisan clear-compiled"
with "Illuminate\\Foundation\\ComposerScripts::postInstall"
post-update-cmd
section, replace "php artisan clear-compiled"
with "Illuminate\\Foundation\\ComposerScripts::postUpdate"
2) Once you have updated your composer.json
, run a composer update
. If you only want to update the framework, you can run composer update laravel/framework
.
After looking over the Github issue you posted in the comments, as well as the related issues, you may be in for a bit of a wait. Taylor would like to put a script in vendor/bin
and change composer.json
to run that, but it looks like they are waiting for a PR from the community, and won't actually implement this themselves.
You haven't done anything wrong; your autoloading is setup correctly. The issue is with Laravel right now.
Moving the command to the post-update-cmd
script doesn't work because artisan will always try to load the cache files when they exist. When running the clear-compiled
command, artisan loads the cache files (part of startup) before it ever tries to delete them.
Your best bet is to manually delete the cache files before artisan gets run. And, you need to do it outside of Laravel/Artisan. So, you can manually delete the files, or you can create a little script to do it and add that to your composer.json
file (for your main project, not your package).
Files to delete:
bootstrap/cache/compiled.php
bootstrap/cache/services.php
bootstrap/cache/compiled.php
bootstrap/cache/services.json
vendor/compiled.php
storage/framework/compiled.php
vendor/services.json
storage/framework/services.json
composer update --no-scripts
this command will ignore command defined in composer.json,otherwise it will excute laravel command which will check if serviceProvider is loaded.