-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
165 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Compiling your application into a standalone binary | ||
|
||
[Putting your Castor application into a PHAR archive](repack.md) can be a good way to easily share and use it in various environments. | ||
|
||
However, you need to ensure that PHP is installed and configured correctly in all the environments where you want to use your Castor app. | ||
This can be a hassle, especially if you don't have control over the environments. | ||
|
||
To simplify things, Castor's `compile` command goes further and puts together a customizable PHP binary with your PHAR archive to make one executable file that can be used in any setting. | ||
|
||
## Pre-requisites | ||
|
||
Follow the `repack` command [pre-requistes](repack.md#pre-requisites) instructions | ||
|
||
> [!WARNING] | ||
> Compiling is not supported yet on Windows. | ||
## Running the Compile Command | ||
|
||
To compile your Castor application, navigate to your project directory and run: | ||
|
||
```bash | ||
vendor/bin/castor compile | ||
``` | ||
|
||
### Options | ||
|
||
Make sure to show the command description to see all the available options: | ||
```bash | ||
vendor/bin/castor compile -h | ||
`````` | ||
### Behavior | ||
|
||
The `compile` command performs several steps: | ||
|
||
1. Executes the `repack` command to build your PHAR archive. | ||
2. Downloads or uses an existing Static PHP CLI tool to compile PHP and the PHAR archive into a binary. | ||
3. If required, it automatically installs dependencies and compiles PHP with the specified extensions. | ||
4. Combines the compiled PHP and your PHAR file into a single executable. | ||
|
||
## Post-Compilation | ||
|
||
Once the compilation is finished, your Castor application is transformed into a standalone binary called `my-app` by default (you can use the `--app-name=` option to change it). | ||
This binary is now ready to be distributed and run in environments that do not have PHP installed. | ||
|
||
You can simply run it like any other executable: | ||
|
||
```bash | ||
./my-app | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters