Question: Question:
I am developing with Laravel 5.
When you create a project, php artisan optimize
will be run automatically and vender/compiled.php
will be generated.
In this state, compiled.php
is preferentially loaded at boot time, and the contents of the service provider that you added are not loaded.
Therefore, I delete compile.php
after creating the project every time.
The reason I noticed this phenomenon was that I added the event handler setting to EventServiceProvider
, but the handler did not fire and I was addicted to it.
Optimize is an effective way to improve performance, but I think it's needed during deployment and not needed during development.
So I have a question.
- Is there any reason why
compiled.php
is generated after the project is created? - Is there a workaround that eliminates the need to manually delete
compiled.php
after each project creation? - Is there anything wrong with my perception above? Is it a phenomenon that is invited for that?
Answer: Answer:
It was a bug that compiled.php was generated after creating the project.
Improved in Laravle v5.1. Improvements have been made in both project creation via composer and project generation with the Laravel installer.
https://github.com/laravel/laravel/commit/2ac993f8d369c0ca367accc93714ad960995f91e
https://github.com/laravel/installer/commit/e93e688c914d535fc7a7fbbfddf0f80a426147c8
Please note that the Laravel installer needs to be updated to v1.2.1.
$ composer global update
$ laravel -V
Laravel Installer version 1.2.1
Also, from v5.1, the output destination of compiled.php has been changed to bootstrap / cache / compile.php.