Giter Club home page Giter Club logo

ftp-deployment's Introduction

FTP Deployment: smart upload Buy me a coffee

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 server and 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.

FTP Deployment is a script written in PHP (requires PHP 5.4 or newer) and will automate the entire process. Just say which local folder to upload and where. This information is stored in a deployment.ini text file, which you can associate with deployment.php script, so deployment will become a one click thing.

php deployment.php deployment.ini

And what does the deployment.ini file contain? Only the remote 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 server
remote = ftp://user:[email protected]/directory
; you can use ftps:// or sftp:// protocols (sftp requires SSH2 extension)

; FTP passive mode
passivemode = yes

; local path (optional)
local = .

; run in test-mode? (can be enabled by option -t or --test)
test = no

; files and directories to ignore
ignore = "
	.git*
	project.pp[jx]
	/deployment.*
	/log
	temp/*
	!temp/.htaccess
"
; is the script allowed to delete remote files? (defaults to yes)
allowdelete = yes

; jobs to run before file upload
before[] = local: lessc assets/combined.less assets/combined.css
before[] = http://example.com/deployment.php?before

; jobs to run after file upload
after[] = remote: unzip api.zip
after[] = http://example.com/deployment.php?after

; directories to purge after file upload
purge[] = temp/cache

; files to preprocess (defaults to *.js *.css)
preprocess = no

Configuration can also be stored in a PHP file.

In test mode (with -t option) uploading or deleting files is skipped, so you can use it to verify your settings.

Item ignore uses the same format as .gitignore:

log - ignore all 'log' files or directories in all subfolders
/log - ignore 'log' file or directory in the root
app/log - ignore 'log' file or directory in the 'app' subfolder
data/* - ignore everything inside the 'data' folder, but the folder will be created on FTP
!data/session - make an exception for the previous rules and do not ignore file or folder 'session'
project.pp[jx] - ignore files or folders 'project.ppj' and 'project.ppx'

Before the upload starts and after it finishes, you can execute commands or call your scripts on the server (see before and 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.

Syncing a large number of files attempts to run in (something like) a transaction: all files are uploaded with extension .deploytmp and then quickly renamed.

An .htdeployment file is uploaded to the server, which contains MD5 hashes of all the files and is used for synchronization. So the next time you run deployment.php, only modified files are uploaded and deleted files are deleted on server (if it is not forbidden by the allowdelete directive).

Uploaded files can be processed by a preprocessor. These rules are predefined in the deployment.php file: .css files are compressed using the YUI Compressor and .js minified by Google Closure Compiler. These tools are already included in the distribution, however, they require the presence of Java.

There is also a rule for expanding mod_include Apache directives. For example, you can create a file combined.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.

In the deployment.ini, you can create multiple sections, i.e. you may have separate rules for data and for application.

ftp-deployment's People

Contributors

dg avatar fprochazka avatar dmkuznetsov avatar frankhildebrandt avatar janpecha avatar mkoubik avatar danielkurecka avatar jozefizso avatar mbohal avatar peci1 avatar kahi avatar smasty avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.