Download the PHP package mpernia/phar-skeleton without Composer
On this page you can find all versions of the php package mpernia/phar-skeleton. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mpernia/phar-skeleton
More information about mpernia/phar-skeleton
Files in mpernia/phar-skeleton
Package phar-skeleton
Short Description A skeleton project to build a PHAR package in PHP
License MIT
Homepage https://github.com/mpernia/phar-skeleton
Informations about the package phar-skeleton
Phar Skeleton
Phar Skeleton is a simple starter project for building a .phar package in PHP.
This repository provides a basic structure to create, compile, and distribute your PHP application as a PHAR archive.
Contents
- Requirements
- Features
- Project Structure
- Getting Started
- Environment Variables
- Usage
- Build with Makefile
- Build with Composer
- Run or distribute the PHAR file
- Error Handling
- Contributing
- License
Requirements
- PHP 8.2 or higher
- PHP
phar.readonlysetting must be disabled makecommand available in your system
Features
- Basic Composer configuration (type = "project").
- PSR-4 autoloading support.
- Simple build script example (
src/Example.php). - Example CLI script (
build/app.phar).
Project Structure
Getting Started
- Install this skeleton (via Composer or by downloading/cloning this repository).
-
Customize your package:
- Update
composer.jsonwith your details. - Modify
src/files to include your application logic. - Edit a file
.envto set environment variables.
- Update
- Build your PHAR:
- Run
composer compileor directlymake. - This will generate a
app.pharfile in the project. - The PHAR file will be created in the specified build directory (default:
./build/app.phar).
- Run
- Run or test your PHAR:
- Run
php build/app.pharorbuild/app.pharto execute the PHAR file.
- Run
Environment Variables
BUILD_DIR: Directory where the PHAR file will be createdPHAR_NAME: Name of the output PHAR file
Usage
Build with Makefile
The project includes a Makefile with several commands to help you build the PHAR file:
Build with Composer
You can also use Composer to build the PHAR file:
Additional Makefile Commands
The following commands have been added to the Makefile:
- check-index: Ensures that the
public/index.phpfile exists. If it does not, it creates the file with a default message. - docker-composer-install: Runs
composer installinside the Composer container to install dependencies. - docker-build-app: Executes
make buildinside the application container to build the PHAR file. - dir-app: Opens a bash shell in the application container for direct access to the app directory.
Run or distribute the PHAR file
-
You can run the PHAR file directly:
Or:
- You can also distribute the PHAR file to other machines or environments, so they can run the application without needing the full source.
Error Handling
- If the
.envfile is missing or incomplete, the build process will show an error message with the required variables - Build errors will be displayed with appropriate error messages and exit codes
Contributing
Feel free to open issues or submit pull requests if you have any suggestions or improvements.
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
License
MIT License. See the LICENSE file for more details.