Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/frankdejonge/poser
Composer Class Aliassing - THIS IS STUPID, DON'T EVER DO THIS, EVER.
https://github.com/frankdejonge/poser
Last synced: 3 days ago
JSON representation
Composer Class Aliassing - THIS IS STUPID, DON'T EVER DO THIS, EVER.
- Host: GitHub
- URL: https://github.com/frankdejonge/poser
- Owner: frankdejonge
- Created: 2012-10-05T23:46:55.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2014-02-13T15:49:16.000Z (over 10 years ago)
- Last Synced: 2024-05-01T23:28:20.950Z (5 months ago)
- Language: PHP
- Homepage:
- Size: 138 KB
- Stars: 39
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# WARNING WARNING, DEPRECATED PACKAGE!
I've made a way better and optimizable version: [FuelPHP/Alias](http://github.com/fuelphp/alias). I strongly recommend using that package instead of this one.
# Poser
[![Build Status](https://secure.travis-ci.org/FrenkyNet/Poser.png)](http://travis-ci.org/FrenkyNet/Poser)
Poser appends itself to the autoloading stack and resolves class aliasses. This all so your classes can pretend to be someone else.
## Usage
```php
'Namespaced\Classname',
// Rename namespace
'Other\Namespaced\Classname' => 'Real\Namespaced\Classname'
// Alias to global
'Classname' => 'Namespaced\Classname',
));
```## Wildcards
With a wildcard like;
```php
Poser\Poser::alias(array(
'NotSo\Deep\*' => 'ACLass\InA\Deep\And\Hidden\Namespace\$1',
));
```
Poser wil act like:
```php
$obj = new NotSo\Deep\Model();
// ACLass\InA\Deep\And\Hidden\Namespace\Model;
```You can also have multiple wildcards:
```php
Poser\Poser::alias(array(
'*\Dude\*\Is\*\Man' => '$1\$2\$3',
));$obj = new Hey\Dude\What\Is\Up\Man()
// Wil stranslate to Hey\WHat\Up
```## Closure translations
You can also modify the translation in a closure.
```php
Poser\Poser::alias(array(
'*\*\Strange' => function($one, $two)
{
return $one.'\\'.$two.'\\Weird';
}
));$instance = new That\Stuffs\Strange();
// Will be a new instance of That\Stuffs\Weird
```## Registering the autoloader
```php
Poser\Poser::register();// Unregister
Poser\Poser::unregister();
```## Multiton usage
You can also register more Posers to the autoloader.
```php
$poser = Poser\Poser::instance('justin_bieber');
// Alias some classes
$poser->alias(array(
'Justin\Bieber' => 'InvalidArgumentException',
));// Register the autoloader
$poser->register();```