Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/00f100/fcphp-autoload
Package to autoload providers, routes and console commands into another composer packages
https://github.com/00f100/fcphp-autoload
autoload autoloader composer files packages php7
Last synced: about 2 hours ago
JSON representation
Package to autoload providers, routes and console commands into another composer packages
- Host: GitHub
- URL: https://github.com/00f100/fcphp-autoload
- Owner: 00F100
- License: mit
- Created: 2018-06-13T23:32:58.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-08-04T19:01:25.000Z (over 6 years ago)
- Last Synced: 2024-05-12T23:02:53.019Z (6 months ago)
- Topics: autoload, autoloader, composer, files, packages, php7
- Language: PHP
- Homepage:
- Size: 22.5 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FcPhp Autoload
Package to autoload providers and routes into another composer packages
[![Build Status](https://travis-ci.org/00F100/fcphp-autoload.svg?branch=master)](https://travis-ci.org/00F100/fcphp-autoload) [![codecov](https://codecov.io/gh/00F100/fcphp-autoload/branch/master/graph/badge.svg)](https://codecov.io/gh/00F100/fcphp-autoload) [![Total Downloads](https://poser.pugx.org/00F100/fcphp-autoload/downloads)](https://packagist.org/packages/00F100/fcphp-autoload)
## How to install
Composer:
```sh
$ composer require 00f100/fcphp-autoload
```or add in composer.json
```json
{
"require": {
"00f100/fcphp-autoload": "*"
}
}
```## How to use
#### Create my `providers.php`
```php
[
'post' => 'SiteController@method'
]
];
```#### Find content in directory
```php
path(string $pathExpression, array $fileNameMatch, array $extensionMatch);/*
Example to find inside composer directory============================================
Example directory:
============================================vendor/
00f100/
fcphp-di/
autoload/
providers.php
prividers.txt
fcphp-i18n/
fcphp-provider/
autoload/
routes.php
doctrine/
doctrine/
instructor/
cake/
bin/
cake/
autoload/
providers.php*/
$autoload->path('vendor/*/*/autoload', ['providers', 'routes'], ['php']);
/*
============================================
Below example match this files:
============================================vendor/00f100/fcphp-di/autoload/providers.php
vendor/00f100/fcphp-provider/autoload/routes.php
vendor/cake/cake/autoload/providers.php
*/
```#### Get content of files
```php
/*
============================================
Get the content using 'get' method
============================================
[
'path/to/route' => [
'post' => 'SiteController@method'
]
]
$arrayProviders = $autoload->get('providers');[
\path\to\SomeClass,
\path\to\package\Cool
]
$arrayRoutes = $autoload->get('routes');
*/
/**
* Method to return autoloaded files
*
* @param string $key Filename
* @return array
*/
$autoload->get(string $fileName);```
## Triggers
#### Before Match
This clousure run before match run
```php
$instance->beforeMatch(function(string $pathExpression, array $fileNameMatch, array $extensionMatch) {
// your code here
});```
#### Before Match Again
This clousure run before match some dir again
```php
$instance->beforeMatchAgain(function(array $paths, array $files, array $extensions, string $path, string $now) {
// your code here
});```
#### Before Storage
This clousure run before storage file content
```php
$instance->beforeStorage(function(string $file, string $filePath) {
// your code here
});```