PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, January 17, 2022

[FIXED] How to use Composer with git pull so that class not found does not comes

 January 17, 2022     composer-php, git, laravel, php     No comments   

Issue

I am using Laravel 5.6.

My Current Code deployment process is as follow

  1. Made some changes to file
  2. Commit and push it to branch.
  3. Once everything is perfect merge it to master and pull master branch to code production server(Where my code is).

My Issue

  1. If I have some dependencies which is maintained by composer. I just add it to current branch and made changes to other files.
  2. When I merge it with master and pull it to production server I need to run composer update command manually.
  3. Server gives errors when we try to access it that it dependencies class or service provider not found(As we need to add it to config/app.php in Laravel) When it is updating composer dependencies.
  4. After updating it is working perfectly.
  5. So I want to avoid that 5-10 sec error which comes while updating composer dependencies.

I have two options

  1. Put Application on maintenance mode while updating code. -> I cannot do that.
  2. Every time whenever there is dependencies upload it using two merge. -> I Don't want to do that.

Is there any other best practices solutions to this problem so that we can avoid such errors.


Solution

You should never update on the production server, just composer install. You can hook this to your merge git action, accordingly to how you deploy to production (CI/CD, scripting or all manual?). Here documentation for git hooks: https://git-scm.com/docs/githooks this is for git-hooks post-merge: https://git-scm.com/docs/githooks#_post_merge



Answered By - Gracz
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing