2017 © Pedro Peláez
 

library autoloader

Expansible Universal Autoloader.

image

exorg/autoloader

Expansible Universal Autoloader.

  • Sunday, May 10, 2015
  • by katheroine
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Autoloader

PHP workflow, (*1)

Expansible Universal Autoloader., (*2)

Getting Started

Prerequisities

The instruction assumes using the Linux operating system or compatible tools for other operating systems., (*3)

Installation

php8.*-cli, Git and Composer required

The recommended way to install Autoloader into the source code of the project is to handle it as code dependency by Composer. Git is needed to fetch packages from version control repositories., (*4)

The php8.*-cli is needed for installing Composer., (*5)

Autoloader installation

Add to your composer.json file appropriate entry by running the following command, (*6)

composer require exorg/autoloader

If it's project set-up stage and no one dependency have been installed yet, run, (*7)

composer install

If another dependencies have been intalled previously, run, (*8)

composer update

Usage

The simplest way to autoload all needed files in executable file is attaching autoload.php file generated by Composer (after running composer install or composer update command) like in following example, (*9)

require_once (__DIR__ . '/vendor/autoload.php');

PSR-4 autoloader

.
└── src
    └── Subject
        └── Core
            └── SomeComponent.php
<?php

namespace Vendor\Package\Subject\Core;

class SomeComponent
{

}

<?php

declare(strict_types=1);

require_once (__DIR__ . '/vendor/autoload.php');

use ExOrg\Autoloader\Autoloader;
use ExOrg\Autoloader\Psr4AutoloadingStrategy;

$psr4Strategy = new Psr4AutoloadingStrategy();
$psr4Strategy->registerNamespacePath('Vendor\Package', './src');

$autoloader = new Autoloader();
$autoloader->setAutoloadingStrategy($psr4Strategy);
$autoloader->register();

$component = new Vendor\Package\Subject\Core\SomeComponent();

$autoloader->unregister();

PSR-0 autoloader

.
└── src
    └── Vendor
        └── Package
            └── Subject
                └── Core
                    └── SomeComponent.php
<?php

namespace Vendor\Package\Subject\Core;

class SomeComponent
{

}

<?php

declare(strict_types=1);

require_once (__DIR__ . '/vendor/autoload.php');

use ExOrg\Autoloader\Autoloader;
use ExOrg\Autoloader\Psr0AutoloadingStrategy;

$psr0Strategy = new Psr0AutoloadingStrategy();
$psr0Strategy->registerNamespacePath('Vendor\Package', './src');

$autoloader = new Autoloader();
$autoloader->setAutoloadingStrategy($psr0Strategy);
$autoloader->register();

$component = new Vendor\Package\Subject\Core\SomeComponent();

$autoloader->unregister();

PEAR autoloader

.
└── src
    └── Subject
        └── Core
            └── SomeComponent.php
<?php

class Subject_Core_SomeComponent
{

}

<?php

declare(strict_types=1);

require_once (__DIR__ . '/vendor/autoload.php');

use ExOrg\Autoloader\Autoloader;
use ExOrg\Autoloader\PearAutoloadingStrategy;

$pearStrategy = new PearAutoloadingStrategy();
$pearStrategy->registerPseudonamespacePath('Subject', './src');

$autoloader = new Autoloader();
$autoloader->setAutoloadingStrategy($pearStrategy);
$autoloader->register();

$component = new Subject_Core_SomeComponent();

$autoloader->unregister();

Fixed autoloader

.
└── src
    └── Subject
        └── Core
            └── SomeComponent.php
<?php

namespace Subject\Core;

class SomeComponent
{

}

<?php

declare(strict_types=1);

require_once (__DIR__ . '/vendor/autoload.php');

use ExOrg\Autoloader\Autoloader;
use ExOrg\Autoloader\FixedAutoloadingStrategy;

$fixedStrategy = new FixedAutoloadingStrategy();
$fixedStrategy->registerClassPath('Subject\Core\SomeComponent', './src/Subject/Core/SomeComponent.php');

$autoloader = new Autoloader();
$autoloader->setAutoloadingStrategy($fixedStrategy);
$autoloader->register();

$component = new \Subject\Core\SomeComponent();

$autoloader->unregister();

Recursive autoloader

.
└── src
    └── Subject
        └── Core
            └── SomeComponent.php
<?php

namespace Subject\Core;

class SomeComponent
{

}

<?php

declare(strict_types=1);

require_once (__DIR__ . '/vendor/autoload.php');

use ExOrg\Autoloader\Autoloader;
use ExOrg\Autoloader\RecursiveAutoloadingStrategy;

$recursiveStrategy = new RecursiveAutoloadingStrategy();
$recursiveStrategy->registerPath('./src');

$autoloader = new Autoloader();
$autoloader->setAutoloadingStrategy($recursiveStrategy);
$autoloader->register();

$component = new \Subject\Core\SomeComponent();

$autoloader->unregister();

Tests

Unit tests

This project has unit tests, which has been built with PHPUnit framework and run on Linux operating system., (*10)

To run tests, write the following command in your command line inside the main Autoloader project directory, (*11)

vendor/bin/phpunit tests/

or use a Composer script, (*12)

composer test

Code style tests

This code follows PSR-1 and PSR-12 standards., (*13)

To run tests for code style write the following command in your command line inside the main Autoloader project directory, (*14)

vendor/bin/phpcs tests/ src/

or use a Composer script, (*15)

composer sniff

You can also use a Composer script for running both tests and check code style, (*16)

composer check

Built with

Versioning

This project is versioning according to SemVer versioning standars. All available releases are tagged., (*17)

Contributing

Please read CONTRIBUTING.md for details on the code of conduct, and the process for submitting pull requests., (*18)

Author

License

This project is licensed under the MIT License - see the LICENSE.md file for details., (*19)

The Versions

10/05 2015

dev-develop

dev-develop

Expansible Universal Autoloader.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

by Katarzyna Krasińska

autoloader exorg

10/05 2015

dev-master

9999999-dev

Expansible Universal Autoloader.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

by Katarzyna Krasińska

autoloader exorg

10/05 2015

1.0

1.0.0.0

Expansible Universal Autoloader.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

by Katarzyna Krasińska

autoloader exorg