hylianshield / vendor-locator-bundle
This bundle allows to locate vendor packages inside a Symfony project.
Installs: 11
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^7.0
- composer/composer: ^1.3.2
- symfony/framework-bundle: ^3.2.1
This package is auto-updated.
Last update: 2024-10-29 04:42:07 UTC
README
This bundle allows to locate composer vendor packages inside a Symfony project.
It interprets the composer.json
in your project root to find the correct vendor
base directory.
The vendor location is configured with a compiler pass, so the path lookup is stored in DI definition cache.
Installation
composer require hylianshield/vendor-locator-bundle:^1.0
Add the following bundle to the app kernel.
<?php use HylianShield\VendorLocatorBundle\HylianShieldVendorLocatorBundle; //... class AppKernel extends Kernel { // ... public function registerBundles() { $bundles = [ // ... new HylianShieldVendorLocatorBundle() ]; // ... } // ... }
Make sure to flush the cache, to activate the compiler pass.
Usage
The file locator service is available as service hylianshield.file_locator.vendor
.
With this service, one can find files relative to the vendor directory:
<?php /** @var \Symfony\Component\Config\FileLocatorInterface $locator */ $locator = $this->get('hylianshield.file_locator.vendor'); echo $locator->locate('hylianshield/vendor-locator-bundle');
Outputs:
/path/to/symfony/vendor/hylianshield/vendor-locator-bundle