-
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.
Add command to build standalone binary
- Loading branch information
Showing
11 changed files
with
400 additions
and
39 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
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,51 @@ | ||
# 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 make things simpler, Castor's `compile` command can help by creating a customizable PHP binary with a PHAR archive, making one executable file that can be used in any setting. | ||
|
||
Just pass your repacked Castor app PHAR as an argument of this command. | ||
|
||
## Pre-requisites | ||
|
||
Follow the [`repack` documentation](repack.md) to output a PHAR archive of your Castor app. | ||
|
||
## Running the Compile Command | ||
|
||
To compile your Castor application, navigate to your project directory and run: | ||
|
||
```bash | ||
vendor/bin/castor compile my-custom-castor-app.phar | ||
``` | ||
|
||
> [!WARNING] | ||
> Compiling is not supported yet on Windows. | ||
### Options | ||
|
||
Make sure to take a look at the command description to see all the available options: | ||
```bash | ||
vendor/bin/castor compile -h | ||
`````` | ||
### Behavior | ||
|
||
The `compile` command performs several steps: | ||
|
||
1. Downloads or uses an existing Static PHP CLI tool to compile PHP and the PHAR archive into a binary. | ||
2. If required, it automatically installs dependencies and compiles PHP with the specified extensions. | ||
3. 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 named `compiled-castor` by default (you can use the `--output=` 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 | ||
./compiled-castor | ||
``` |
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
Oops, something went wrong.