Download the PHP package forrest79/deploy-php without Composer
On this page you can find all versions of the php package forrest79/deploy-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package deploy-php
Forrest79/DeployPhp
Simple assets builder and application deploy helper for PHP projects.
Requirements
Forrest79/DeployPhp requires PHP 8.0 or higher.
Installation
The recommended way to install Forrest79/DeployPhp is through Composer:
Documentation
Assets
This is a simple assets builder. Currently, it supports copying files, compiling and minifying less files, sass files and JavaScript (simple minifier UglifyJS or complex rollup.js + recommended Babel) files and in debug environment also generating map files.
For compiling and minifying is required node.js with installed npm packages less, sass, uglify-js or rollup (babel) environment. In Debian or Ubuntu, you can do it like this (-g option install package globally in the system, not in your repository):
Using is straightforward. Examples show how this works with Nette Framework. Just create new instance Forrest79\DeployPhp\Assets class and pass temp directory, assets source directory and configuration array to constructor. key is a directory to process (for ) or target file (for DeployPhp\Assets::UGLIFYJS, DeployPhp\Assets::ROLLUP or DeployPhp\Assets::LESS) or directory (for DeployPhp\Assets::SASS) for source data and value can be simple DeployPhp\Assets::COPY which tells to copy this file/directory from source to destination or another array with items:
- required
type- with valueDeployPhp\Assets::COPYto copy file/directory orDeployPhp\Assets::LESSto compile and minify less to CSS orDeployPhp\Assets::UGLIFYJSto concatenate and minify JavaScripts orDeployPhp\Assets::ROLLUPto use modern JavaScript environment - optional
env- if missing, this item is processed for debug and production environment, or you can specify concrete environmentDeployPhp\Assets::DEBUGorDeployPhp\Assets::PRODUCTION - required
filefortype => DeployPhp\Assets::LESS- with source file to compile and minify - required
fileorfilesfortype => DeployPhp\Assets::SASS- with source file or files to compile and minify - required
filesfortype => DeployPhp\Assets::UGLIFYJS- with source files to concatenate and minify - required
filefortype => DeployPhp\Assets::ROLLUP- with source file to process (example configuration is below)
The next two parameters are callable function, the first is for reading hash from file, and the second is to write hash to file. In example is shown, how you can write it to neon and use it with Nette DI.
Last (fourth) parameter is optional and define an array with optional settings. More about this is under the example.
To build assets you need first call buildDebug($configNeon, $destinationDirectory) or buildProduction($configNeon, $destinationDirectory) method.
$configFilefile where will be stored actual assets hash that you can use in your application$destinationDirectorydirectory where assets will be built
First builds assets only if there was some changed file and creates new hash from all files timestamps (and also create map files), the second builds assets every time and creates hash from every file content.
rollup.js environment with Babel
This is modern JavaScript building configuration. You must prepare rollup configuration file in your assets directory:
Create files assets\rollup.config.js:
In your HTML, you can use both files like this:
Example
In deploy/assets.php:
Neon file with hash has this structure:
In deploy/assets.local.php you can define local source assets directory, if you're using some virtual server, where the paths are different from your host paths. This directory will be used for JS and CSS map files to property open source files in the browser console:
Or you need to specify here your local server bin directory, if differ from /usr/bin:/bin (directory, where is node binary):
In app/bootstrap.php:
In debug mode, hash is calculated from every assets file timestamp - creating hash is fast (if you change file or add/remove some file, hash is changed and assets are automatically rebuilt before the request is performed).
In Nette, you need to define you own Assets extension, that will read hash from and with some sort of service, you can use it in your application. For example, like this:
In your application, you can use hash as query parameter or as virtual path in web server, example for nginx, load assets at path :
When building application:
Hash is computed from all file content, so hash is changed only when some file content is changed or the same file is added/remove (creating hash is slow).
Build and deploy
Contains just some helper methods to checkout from GIT, copy files via SFTP, and run commands via SSH. For documentation look at example.
Example
Composer monorepo
IF you're using monorepo for you applications, you need simple tool to prepare correct composer.lock. This is the simple one for a repository that meets these requirements:
- one shared global vendor directory with all libraries
- more applications with local vendors that on local development using the shared one and are installed on production
Be careful, using this tool update is always performed on the global composer! The next step is copy global composer to the local one and update is also performed here. After this is local vendor cleaned.
Just for hint, differences between global and locals composer.json are shown. This may not be a mistake.
This tool can handle global composer in neon format - you need Nette\Neon in your vendor and Composer neon plugin
Example:
- global vendor is committed in repository and to prepare production build, global vendor is copied to the local one and
composer installis executed in the app directory, so only needed packages are kept here
Second parameter to
ComposeMonorepoconstructor is optional parameters tocomposer updatecommand.