Alien helps you to create alias for your class namespace. Its also injected all the dependencies of your class.
54
2
3
Package Data
Maintainer Username: IftekherSunny
Maintainer Contact: iftekhersunny@hotmail.com (Iftekher Sunny)
Package Create Date: 2015-07-10
Package Last Update: 2015-09-18
Home Page: https://packagist.org/packages/sun/alien
Language: PHP
License: MIT
Last Refreshed: 2024-03-25 03:04:15
Package Statistics
Total Downloads: 54
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 2
Total Watchers: 3
Total Forks: 0
Total Open Issues: 0

Alien

Build Status Total Downloads Latest Stable Version Latest Unstable Version License

Alien helps you to create alias for your class namespace. Its also injected all the dependencies of your class.

Installation Process

Just copy Alien folder somewhere into your project directory. Then include Alien autoloader.

 require_once('/path/to/Alien/autoload.php');

Alien is also available via Composer/Packagist.

 composer require sun/alien

You need to call Alien load method to initialize everything.

 Sun\AlienLoader::load();

Configuration

If you install Alien manually just open config.php file located at Alien/config.php.

If you install Alien via composer you need to publish Alien configuration file. Run this command in your terminal to publish alien configuration file.

 Php vendor/sun/alien/publish

Then, open alien.php file located at config/alien.php.

Added your alias and namespace. Like as..

 return [
     'File' => 'Sun\FilesystemAlien',
     'Mail'	=> 'SunMailer\MailerAlien',
     'View'	=> 'SunMailer\ViewAlien'

 ];

Creating Alien

You can create Alien by extending Alien class. Here an example -

namespace Sun;

class FilesystemAlien extends \Sun\Alien
{

    /**
     * To register Alien
     *
     * @return string namespace
     */
    public static function registerAlien()
    {
        return 'Sun\Filesystem';
    }
}

Now you can use any method of your class static way ( without creating object of your class ).

Example:

Let, Filesystem class has a method create(). Calling create method of Filesystem class -

$filesystem = new Sun\Filesystem;
$filesystem->create();

Using Alien Now, you can also call create method by this way -

File::create();

Testing Alien

You can test your alien class, here an example

$mocked = File::shouldReceive('create')
                ->once()
                ->andReturn('mocked');

$this->assertEquals('mocked', $mocked); // true

Don't forget to call close method of the mockery class. Here an example for the PHPUnit testing framework

public function tearDown()
{
    Mockery::close();
}

License

This package is licensed under the MIT License