Welcome Guest, Not a member yet? Register   Sign In
vendor folder for deployment
#1

Hi,

when install CI using composer, like:
composer create-project codeigniter4/appstarter project-root

I got a long list of folders under vendor.

this is different than manually install, the manual install I have only one 'system' folder for CI.

Now, my question is, when I need to deploy the project to production web server, do I need to deploy all the folders under vendor? if yes, how to get a clean deployment, like without all the test/doc folder and other useless files? If no (the manual install has no these folders, and it is working and looks clean), why the composer download all of them? 

I'd like to keep my deployment clean but without loosing dependencies. what is the best practice to use composer and keep a clean deployment/project.

thanks,
Reply
#2

(This post was last modified: 11-18-2020, 11:06 PM by tgix.)

(11-18-2020, 08:31 AM)alanshen209 Wrote: I'd like to keep my deployment clean but without loosing dependencies. what is the best practice to use composer and keep a clean deployment/project.

Yes, you need the vendor directory.

I keep my project in git and this is how I deploy my projects:
First commit and push the code to the repository. I have vendor in .gitignore so I don't have all that stuff in the repo with my code.

Then building (I use Bamboo, but a shell script would do):
1) clone the repository to a directory
2) running composer install to install all packages (including development packages)
3) running phpunit to go through all the tests
4) running composer --no-dev update to remove all composer packages that are for development and testing
5) deleting my own tests directory

I then have a tested and small package of the project ready to deploy. After this, I use Docker to create an image to run in Amazon Web Services, but that's another story.
Reply
#3

What tgix stated is correct, but just to be clear: you should NOT deploy your vendor directory. It should be created by Composer form your composer.lock file (assuming you are installing in place). vendor should never be a part of your project code.
Also, “deleting my own tests directory” you can handle this with a .gitattributes file.
Reply
#4

thanks for your replies, but when I run
composer install --no-dev
I still got the kint and laminas folder created, they are not in the manual download CI files. why is that? I am here creating some small and simple site, don't want to go to complicated.

and what are the options for "build" PHP CI project beside "bamboo".
Reply




Theme © iAndrew 2016 - Forum software by © MyBB