简体   繁体   中英

PHP Remove Phing after PROD Deploy

We are currently using phing on deployment from jenkins to our different environments. We use it to do some cleanup. We would like to remove phing from our source/vendor folder after the build is completed.

Can phing remove itself as a final build step?

Or should i just be doing an rm -rf phing/?

There are two parts to this answer:

Solution for Question

Your Phing installation should be done with composer. Do composer require phing/phing - and then you can use vendor/bin/phing to run your build.xml file (instead of say using a global install).

Then, when you're done, your last step to run could be composer remove phing/phing

Suggested Workflow

So, the idea with something like Jenkins is that you should be using it to do all of your build and processing on a build system. Then, it (Jenkins) is the tool that can do anything else on the remote systems for you. So, instead of having phing on the deployed server and then have it doing tasks, you'd tell Jenkins to do those tasks remotely. (This might be accomplished by each step having to re-ssh into that server to execute a new step). As these steps are part of the deploy process too, if any of them fail, the build will be considered failed and you'll have that insight. So, that being said, the solution I suggest is above, but I'd recommend changing everything else up.

Imagine your project needs many dependencies, for example ramsey/uuid , phing/phing and pds/skeleton . Use composer require to add dependencies, but use --dev option when adding development depdendencies:

composer require ramsey/uuid
composer require --dev phing/phing
composer require --dev pds/skeleton

The content of your composer.json should be the following:

{
  "require": {
    "ramsey/uuid": "^3.8"
  },
  "require-dev": {
    "pds/skeleton": "^1.0",
    "phing/phing": "^2.16"
  }
}

To install all your dependencies use the following command:

composer install 

Now, if you want to remove your development dependencies type:

composer install --no-dev

The last command will only install your production dependencies and remove your development dependencies from vendor directory at once.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM