2017 © Pedro Peláez
 

composer-plugin easy-extend

Easy extends class implementation for PHP

image

apishka/easy-extend

Easy extends class implementation for PHP

  • Thursday, February 1, 2018
  • by damnedest
  • Repository
  • 2 Watchers
  • 0 Stars
  • 1,704 Installations
  • PHP
  • 11 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 32 Versions
  • 0 % Grown

The README.md

PHP easy extend

Current build status image, (*1)

What is easy extend?

This is composer component which helps developers to write common libraries and extend them in project., (*2)

Quick start

  • Add easy-extend to composer requirements of your library
"require": {
    "apishka/easy-extend": "^1.0.0"
}
  • Create .apishka.php (structure documentation). Most common file looks like this:
<?php

return array(
    'easy-extend' => array(
        'finder' => function($finder)
        {
            $finder
                ->in('source/')
                ->files()
                ->name('*.php')
            ;

            return $finder;
        }
    ),
);
 ```
 - Run ``composer update``
 - Implement traits to classes which you want to be easy extendable.

# How to extend?
## Extending classes
Some library has basic implementation of class you want extend and this library implements EasyExtend:
```php
class Library_User_Implementation
{
    /**
     * We have to include trait
     */
    use Apishka\EasyExtend\Helper\ByClassNameTrait;
}

One thing you have to do to extend this class and don't rewrite any library code, or check where new user class should pass is to extends that class:, (*3)

class My_Library_User_Implementation extends Library_User_Implementation
{
}

One thing you have to do is create new instance of class using, (*4)

Library_User_Implementation::apishka(); // instanceof My_Library_User_Implementation

All libraries can be easy extended for you custom project with your custom requirements. No need to require tons of code., (*5)

Items routing

Create router and realize two methods:, (*6)

class My_Library_ItemsRouter extends \Apishka\EasyExtend\Router\ByKeyAbstract
{
    protected function isCorrectItem(\ReflectionClass $reflector)
    {
        return $reflector->isSubclassOf('My_Library_ItemsInterface');
    }

    protected function getClassVariants(\ReflectionClass $reflector, $item)
    {
        return $item->getAliases();
    }
}

Create item:, (*7)

class My_Library_ItemApple implements My_Library_ItemsInterface
{
    public function getAliases()
    {
        return array(
            'apple',
            'red_apple',
        );
    }
}

Now you can get class by alias:, (*8)

var_dump(
    get_class(My_Library_ItemsRouter::apishka()->getItem('apple')
); // My_Library_ItemApple

var_dump(
    get_class(My_Library_ItemsRouter::apishka()->getItem('red_apple')
); // My_Library_ItemApple

Also you can extend your item:, (*9)

class My_Library_ItemRedApple extends My_Library_ItemApple
{
}

// after ./vendor/bin/easy-extend
var_dump(
    get_class(My_Library_ItemsRouter::apishka()->getItem('apple')
); // My_Library_ItemRedApple

The Versions

01/02 2018

dev-master

9999999-dev

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

01/02 2018

2.0.4

2.0.4.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

04/01 2018

2.0.3

2.0.3.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

04/01 2018

2.0.1

2.0.1.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

02/01 2018

2.0.0

2.0.0.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

14/04 2017

1.3.0

1.3.0.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

02/01 2017

1.2.18

1.2.18.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

31/12 2016

1.2.17

1.2.17.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

17/12 2016

1.2.16

1.2.16.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

18/06 2016

1.2.15

1.2.15.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

27/03 2016

1.2.14

1.2.14.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

27/03 2016

1.2.13

1.2.13.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

15/02 2016

1.2.12

1.2.12.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

15/02 2016

1.2.11

1.2.11.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

15/12 2015

1.2.10

1.2.10.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

15/12 2015

1.2.8

1.2.8.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

24/07 2015

1.2.7

1.2.7.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

24/07 2015

1.2.6

1.2.6.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

24/07 2015

1.2.5.1

1.2.5.1

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

23/07 2015

1.2.5

1.2.5.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

23/07 2015

1.2.4

1.2.4.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

20/06 2015

1.2.3

1.2.3.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

19/06 2015

1.2.2

1.2.2.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

19/06 2015

1.2.1

1.2.1.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

19/06 2015

1.2.0

1.2.0.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

06/06 2015

1.1.0

1.1.0.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

06/06 2015

1.0.5

1.0.5.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

06/06 2015

1.0.4

1.0.4.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

05/06 2015

1.0.3

1.0.3.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

05/06 2015

1.0.2

1.0.2.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

05/06 2015

1.0.1

1.0.1.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending

05/06 2015

1.0.0

1.0.0.0

Easy extends class implementation for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Reykh

class extend composer-plugin extending