2017 © Pedro Peláez
 

package fcphp-autoload

Autoload providers and routes into composer vendor package

image

00f100/fcphp-autoload

Autoload providers and routes into composer vendor package

  • Sunday, June 24, 2018
  • by 00F100
  • Repository
  • 1 Watchers
  • 0 Stars
  • 26 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

FcPhp Autoload

Package to autoload providers and routes into another composer packages, (*1)

Build Status codecov Total Downloads, (*2)

How to install

Composer:, (*3)

$ composer require 00f100/fcphp-autoload

or add in composer.json, (*4)

{
    "require": {
        "00f100/fcphp-autoload": "*"
    }
}

How to use

Create my providers.php

<?php

return [
    \path\to\SomeClass::class,
    \path\to\package\Cool::class
];

Create my routes.php

<?php

return [
    'path/to/route' => [
        'post' => 'SiteController@method'
    ]
];

Find content in directory

<?php

use FcPhp\Autoload\Autoload;

/**
 * Method to load path and find match's
 *
 * @param string $pathExpression Directory to find file(s)
 * @param array $fileNameMatch List of filename
 * @param array $extensionMatch List of enable extensions
 * @return void
 */
$autoload = Autoload::getInstance();
$autoload->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

/*
    ============================================
    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, (*5)


$instance->beforeMatch(function(string $pathExpression, array $fileNameMatch, array $extensionMatch) { // your code here });

Before Match Again

This clousure run before match some dir again, (*6)


$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, (*7)


$instance->beforeStorage(function(string $file, string $filePath) { // your code here });

The Versions

24/06 2018

dev-master

9999999-dev https://github.com/00f100/fcphp-autoload

Autoload providers and routes into composer vendor package

  Sources   Download

The Requires

  • php 7.2.*

 

The Development Requires

composer package provider vendor routes autoload subpackage

24/06 2018

0.3.0

0.3.0.0 https://github.com/00f100/fcphp-autoload

Autoload providers and routes into composer vendor package

  Sources   Download

The Requires

  • php 7.2.*

 

The Development Requires

composer package provider vendor routes autoload subpackage

16/06 2018

0.2.0

0.2.0.0 https://github.com/00f100/fcphp-autoload

Autoload providers and routes into composer vendor package

  Sources   Download

The Requires

  • php 7.2.*

 

The Development Requires

composer package provider vendor routes autoload subpackage

15/06 2018

0.1.1

0.1.1.0 https://github.com/00f100/fcphp-autoload

Autoload providers and routes into composer vendor package

  Sources   Download

The Requires

  • php 7.2.*

 

The Development Requires

composer package provider vendor routes autoload subpackage

14/06 2018

0.1.0

0.1.0.0 https://github.com/00f100/fcphp-autoload

Autoload providers and routes into composer vendor package

  Sources   Download

The Requires

  • php 7.2.*

 

The Development Requires

composer package provider vendor routes autoload subpackage