Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dxw/phar-install
Bundle up contents of vendor/ into vendor.phar file
https://github.com/dxw/phar-install
composer govpress packagist php
Last synced: about 2 months ago
JSON representation
Bundle up contents of vendor/ into vendor.phar file
- Host: GitHub
- URL: https://github.com/dxw/phar-install
- Owner: dxw
- License: mit
- Created: 2015-10-22T14:00:51.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2022-11-20T13:47:08.000Z (about 2 years ago)
- Last Synced: 2024-11-14T15:27:11.790Z (3 months ago)
- Topics: composer, govpress, packagist, php
- Language: PHP
- Homepage:
- Size: 45.9 KB
- Stars: 18
- Watchers: 11
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: COPYING.md
Awesome Lists containing this project
README
# phar-install
Tool to bundle up contents of `vendor/` into `vendor.phar` file.
This may be useful if you want to put your project in a web-readable directory but you don't want to trawl through all the files in `vendor/` to make sure none of them could allow an attacker to do something they shouldn't be able to do.
## Usage
Add the following to `composer.json`:
```
"scripts": {
"post-update-cmd": "vendor/bin/phar-install"
},
```Add phar-install:
```
composer require --dev dxw/phar-install
````vendor.phar` will be rebuilt automatically every time `composer update` or `composer require` is run.
Now just replace `require(__DIR__.'/vendor/autoload.php');` with `require(__DIR__.'/vendor.phar');`.
### Get composer's autoloader
You can also get access to the autoloader object if needed. The phar file will return the autoloader. With this functionality you can add on your own project's namespaced files into the autoloader.
```php
$autoload = require_once __DIR__ . '/vendor.phar';
$autoload->add('MyNamespace', __DIR__ . '/src');
```## Copyright
Copyright dxw 2015 - see [COPYING.md](COPYING.md)