- Notifications
You must be signed in to change notification settings - Fork89
A tool for automated deployment of web applications to an FTP server.
License
dg/ftp-deployment
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
FTP deployment is a tool for automated deployment to an FTP server.
There is nothing worse than uploading web applications to FTP server manually,using tools like Total Commander. (Although, editing files directly on the serverand then trying to keep some kind of synchronization is even worse ;-)
Once the process is automated, it costs you a fraction of time and minimizes the risk of error(didn't I forget to upload some files?). There are lots of sophisticated deploying techniques available today,but many people are still using FTP. This tool is designed for them.
Do you like FTP Deployment? Are you looking forward to the new features?
Thank you!
FTP Deployment is a script written in PHP and will automatethe entire process. Just say which local folder to upload and where. Thisinformation is stored in adeployment.ini
text file, which you can associatewithdeployment
script, so deployment will become a one click thing.
php deployment deployment.ini
And what does thedeployment.ini
file contain?Only theremote
item is required, all the others are optional:
; log file (defaults to config file with .log extension)log = ...; directory for temporary files (defaults to system's temporary directory)tempDir = /temp/deployment; enable colored highlights? (defaults to autodetect)colors = yes[my site]; Optional section (there may be more than one section).; remote FTP serverremote = ftp://user:secretpassword@ftp.example.com/directory; you can use ftps://, sftp://, file:// or phpsec:// protocols (sftp requires SSH2 extension; phpsec uses phpseclib library); do not like to specify user & password in 'remote'? Use these options:user = ...password = ...; FTP passive modepassiveMode = yes; local path (optional)local = .; run in test-mode? (can be enabled by option -t or --test)test = no; files and directories to ignoreignore =".git*project.pp[jx]/deployment.*/logtemp/*!temp/.htaccess"; explicit list of files and directories to include (by default includes all files and directories)include ="/app/app/*/index.php"; is allowed to delete remote files? (defaults to yes)allowDelete = yes; jobs to run before uploading; local jobs are done even if there is no need for synchronizationbefore[] = local: git diff-index --quiet HEAD; ensures Git working directory is cleanbefore[] = local: composer install --no-dev --classmap-authoritative; installs production vendorbefore[] = local: lessc assets/combined.less assets/combined.cssbefore[] = http://example.com/deployment.php?before; jobs to run after uploading and before uploaded files are renamedafterUpload[] = http://example.com/deployment.php?afterUpload; directories to purge after uploadingpurge[] = temp/cache; jobs to run after everything (upload, rename, delete, purge) is done; local jobs are done even if the synchronization did not take placeafter[] = remote: unzip api.zipafter[] = remote: chmod 0777 temp/cache; change permissionsafter[] = upload: config.server.neon app/config.local.neonafter[] = http://example.com/deployment.php?afterafter[] = local: git reset HEAD --hard; reverts all changes in working directory; files to preprocess (defaults to none)preprocess = *.js *.css; file which contains hashes of all uploaded files (defaults to .htdeployment)deploymentFile = .deployment; default permissions for new files (defaults to none)filePermissions = 0644; default permissions for new directories (defaults to none)dirPermissions = 0755
In the config file you can create multiple sections (like[my site]
), so you may have separaterules for data and for application.
Configuration can also be stored in aPHP file.
In test mode (with-t
option) uploading or deleting files is skipped, so you can use itto verify your settings.
Itemignore
uses the similar format to.gitignore
:
log - ignore all 'log' files or directories in all subfolders/log - ignore 'log' file or directory in the rootapp/log - ignore 'log' file or directory in the 'app' in the rootdata/* - ignore everything inside the 'data' folder, but the folder will be created on FTP!data/db/file.sdb - make an exception for the previous rule and do not ignore file 'file.sdb'project.pp[jx] - ignore files or folders 'project.ppj' and 'project.ppx'
Before the upload starts, after it finishes and after all jobs, you can execute commands or call your scripts onthe server (seebefore
,afterUpload
,after
), which can, for example, switch the server to a maintenance mode.If you use PHP config, you can run lambda function with deployment environment:
<?phpreturn ['remote' =>'ftp://user:secretpassword@ftp.example.com/directory','local' =>'.','before' => [function (Deployment\Server$server,Deployment\Logger$logger,Deployment\Deployer$deployer) {...do something},],...];
Syncing a large number of files attempts to run in (something like) a transaction: all files areuploaded with extension.deploytmp
and then quickly renamed.
An.htdeployment
file is uploaded to the server, which contains MD5 hashes of all the files andis used for synchronization. So the next time you rundeployment
, only modified files are uploadedand deleted files are deleted from server (if it is not forbidden by theallowDelete
directive).
Uploaded files can be processed by a preprocessor. These rules are predefined:.css
filesare compressed using the clean-css and.js
are minified by UglifyJS or UglifyES (both via Node.js tool).
There is also a rule for expandingmod_include Apache directives.For example, you can create a filecombined.js
:
<!--#include file="jquery.js" --><!--#include file="jquery.fancybox.js" --><!--#include file="main.js" -->
This tool will combine scripts together and minify them with the Closure Compiler to speed-up your website.
FTP Deployment 3.6 requires PHP 8.0 or later. It also requires openssl extensions for ftps:// and SSH2 extension for sftp:// connections.
The easiest way to obtain FTP Deployment is to downloada single PHAR file.
If you want to use minification, installNode.js,UglifyJS 3for JavaScript minification andclean-css for CSS minification.
npm install uglify-js -gnpm install clean-css-cli -g
Or you can install it using Composer:
composer create-project dg/ftp-deployment
Are you looking for php_ssh2.dll?
Need SSH authenticate using a public key?
publicKey = '/key/id_rsa.pub'privateKey = '/key/id_rsa'passPhrase = 'yourpass' #optional - If needed passphrase for privateKey
About
A tool for automated deployment of web applications to an FTP server.