Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bytefury's avatar

Deploy Laravel to shared hosting with git.

I am having a hard time trying to find the best way to solve this problem.

I upload all my files except vendor files to git repository and pull them on the server using git. But when i add service providers to config.php , php clear-compiled command throws an error on the server while doing composer update or composer install on the server because it doesn't exist yet as i haven't updated composer yet.

I can get through the problem by editing composer.json and removing those pre-post clear-compiled commands but i was looking for a better way to solve this.

Have you guys faced this problem? If you have a suggestion then please let me know!

0 likes
1 reply
cristian9509's avatar

@bytefury First, do you add service providers to app.php inside the config folder?

Regarding your problem. Inside composer.json you will find scripts. Check this line

"pre-update-cmd": [
            "php artisan clear-compiled"
        ],

When you try to run a composer update, it will first try to do php artisan clear-compiled. It will not work since there are no dependencies yet installed.

You need to run first

composer install

and then everything should be working fine!

If composer install does not work you might wanna clone or pull your git repo again.

Please or to participate in this conversation.