I am running my Laravel app on a very slow server, and running php artisan optimize makes a huge difference.
The obvious disadvantage: it does not react to file changes.
I need both:
- Quick response from a file change. The quickest is to
optimize:clearright after something changed - A fast loading application. Meaning, running
optimize.
MY SPEC is an attempt of remote computing
- PHPStorm
- rsync -zar. Through SSH tunneling on change
- git is on my local machine on Windows (hate me)
- server is on ubuntu server
THE STRAIGHTFORWARD SOLUTION: create a watcher script that would watch for any file changes and:
- if file changed and the app is cached: run
optimize:clear - if a second has passed and there is no file changed then run
optimize
PROBLEMS
- Sometimes e.g. on branch change there are 100 file changes and rsync updates every file one by one, thus this might trigger the script 100 unnecessary times
- Laravel is running on sail and for some reason everytime I run a command in the container, it takes 1-2 second to execute. Being inside the container fixes this delay.
Did someone attempted such a setup? Any suggestions?
Any other solutions/ideas are welcome.
Thanks
I think the solution would be to implement a cli script that is responsible for running a command and once the command is executed, then
optimize, likewhich executes the argument you passed and then optimizes it. If your script is called foo.sh, then you can run
This way, whatever command you want to run afterwards will be executed so.