Download the PHP package brunonatali/install without Composer
On this page you can find all versions of the php package brunonatali/install. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download brunonatali/install
More information about brunonatali/install
Files in brunonatali/install
Package install
Short Description Provide installation capability to a repository.
License MIT
Informations about the package install
Install
Provide installation capability to a repository.
Table of Contents
- Before start
- Folder structure
- Quickstart example
- Individual
- All apps
- Executable program
- Post install script
- Use pid file
- Select shell to use
- Restart on failure
- Kill child process
- Require app
- Require service
- After service
- Install
- License
Before start
Before you begin, consider reviewing your code and understanding that this is a tool for automating the installation of an application made in PHP to run on the CLI or as a service in a Linux environment.
Observe that if service was instaled this component will update .service file and perform a daemon-reload, and if is active (runing) before install starts, service will be autoatically started after instalation is finished.
Note. Not supported on Windows.
Folder structure
Prepare the folder structure as shown below:
Note. If you are unsure how to create your 'my_program_executable' go to Executable program.
Quickstart example
Individual
A common use is the individual installation of the application, for that, consider having the folder structure as shown in Folder structure
.
-
Let's create a simple configuration file, "installation / install-instructions.json":
-
Let's add a script for auto installation "installation / install.php":
- Finally perform the installation:
This will make the contents of the "pbin" folder become executable, as well as create a service on the system with the name "My1stProgram" that will execute the file "my_program_executable".
At the end will call script myScript.sh (under /post-install), to do some adjusts that you need, like call other aplication, change some file attribute or remove. Learn more
An "require" is a array that tell which apps your app depends.
Note that a symlink is created in "/usr/sbin", that way you can run the application by typing in the terminal:
All apps
In this example, it is assumed that the folder structure shown in Folder structure
and at least the configuration file "install-instructions.json" is created within all the applications you intend to install.
Within the Factory class there is a static function to make the installation of several applications very easy:
The simplest and most direct way to perform the installation of all applications is to run the following command on the terminal:
Is possible to skip some app installation (partially or entirely).
To do this, you need to pass an array with app name in key, as follows:
Note. The need to run as root, as it will interact with systemd and create / update processes within the system.
Executable program
An executable program considered for this tool basically contains:
Post install script
You can create a bash script to run after installation. For now, this script could do anything.
To help localization, an environment variable 'INSTALL_DIR' has been added.
Use pid file
Could be configured to use a pid file to control service.
For this, place an "control-by-pid" in service config:
An pid file is created in \var\run\MyApp.pid when start and removed when stops.
Select shell to use
To help service load / run using all configs, linux shell is called on execution and "sh" is used for default.
Just one config is allowed, to change this, place an "shell" in service config with "bash":
Restart on failure
Systemd could restart service if service fails.
For this, place an "restart-on-abort" in service config:
Kill child process
Seting "kill-child" to false will make systemd to let all child of the main process alive on stop / restart.
For this, place an "kill-child" in service config:
Remember to manually kill all remaining process to prevent system mem overflow.
Require app
With "require" set in your config.json you could set which app your application depends.
Ex. If you have application called "myCar", you can set "require", like this:
With this, Install whill install "engine" and "wheelsNtires" before install "myCar"
Note 1. This will be handled automatically when called from \BrunoNatali\Install\Factory::installAll().
To handle manually, an 'require-installed' must be passed to install()
Note 2. In the above example, don't matther what is the value of require-installed item (*EXCEPT FOR 'force' that is reserved internally), just need to be registered as a key.
Require service
Configures systemd.unit 'Requires' to defined service
After service
Configures systemd.unit 'After' specific service
Install
The recommended way to install this library is through Composer. New to Composer?
This project follows SemVer. This will install the latest supported version:
This project aims to run on Linux and thus does not require any PHP extensions, but actually not tested in all environments. If you find a bug, please report.
License
MIT, see LICENSE file.