Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

00f100/fcphp-autoload

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

00f100/fcphp-autoload

Autoload providers and routes into composer vendor package

Source
Packagist
Version
0.3.1
Version published
Maintainers
1
Created
Source

FcPhp Autoload

Package to autoload providers and routes into another composer packages

Build Status codecov Total Downloads

How to install

Composer:

$ composer require 00f100/fcphp-autoload

or add in composer.json

{
    "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


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

Before Match Again

This clousure run before match some dir again


$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


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

FAQs

Package last updated on 04 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts