2017 © Pedro Peláez
 

library annotations

Webiny Annotations Component

image

webiny/annotations

Webiny Annotations Component

  • Friday, September 29, 2017
  • by SvenAlHamad
  • Repository
  • 2 Watchers
  • 1 Stars
  • 68 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 23 Versions
  • 3 % Grown

The README.md

Annotations Component

This simple component lets you read annotations assigned to a class, method or a property., (*1)

Install the component

The best way to install the component is using Composer., (*2)

composer require webiny/annotations

For additional versions of the package, visit the Packagist page., (*3)

Configuration and setup

The component configuration is minimal, you just need to define the bridge dependency. The built-in bridge uses Minime\Annotations library., (*4)

Annotations:
    Bridge: \Webiny\Component\Annotations\Bridge\Minime\Annotations
    # You don't need this part if you are using Composer autoload.
    ClassLoader:
        Minime\Annotations: /var/www/Vendors/Minime/Annotations/src

Once defined, you can start parsing the annotations. The best approach is to use the AnnotationsTrait. Let's say that this is the class that you wish to parse the annotations from., (*5)

/**
 * This is a class description with some annotations.
 *
 * @prop SomeProperty that has a string value.
 * @author.name AuthorName
 * @author.email author@name.com
 * @author.website.url http://www.webiny.com
 * @author.website.desc My website
 *
 */
class TestClass
{
    /**
     * @var SomeVarAnnotation
     * @public
     */
    var $someVar;

    /**
     * @access.role ADMIN
     * @access.level 3
     * @name SomeName
     */
    private $_anotherVar;

    /**
     * @post @get
     * @cache.ttl 10
     * @cache.store true @cache.key cacheKey
     * @accept ["json", "xml"]
     */
    function someMethod()
    {

    }
}

In your class, where you wish to do the actually parsing, just use the AnnotationsTrait. Trait methods return an instance of ConfigObject giving you the option to use the get method and to chain the namespaces. Annotation namespaces are fully supported, giving you the possibility to organize the annotations in much cleaner way., (*6)

class MyClass
{
    use AnnotationsTrait;

    function getClassAnnotations()
    {
        $classAnnotations = $this->annotationsFromClass('TestClass');
        $classAnnotations->prop; // SomeProperty that has a string value.
        $classAnnotations->author->website->url; // http://www.webiny.com
    }

    function getPropertyAnnotations()
    {
        $someVarPropertyAnnotations = $this->annotationsFromProperty('TestClass', 'someVar');
        $someVarPropertyAnnotations->public; // returns "true"
    }

    function getMethodAnnotations()
    {
        $methodAnnotations = $this->annotationsFromMethod('TestClass', 'someMethod');
        $methodAnnotations->cache->key; // cacheKey
        $methodAnnotations->accept; // [0 => "json", 1 => "xml"]
    }
}

Resources

To run unit tests, you need to use the following command:, (*7)

$ cd path/to/Webiny/Component/Annotations/
$ composer.phar install
$ phpunit

The Versions

29/09 2017

dev-master

9999999-dev http://www.webiny.com/

Webiny Annotations Component

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sven Al Hamad
by Pavel Denisjuk

phpdoc annotations

29/09 2017

1.6.x-dev

1.6.9999999.9999999-dev http://www.webiny.com/

Webiny Annotations Component

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sven Al Hamad
by Pavel Denisjuk

phpdoc annotations

29/09 2017

v1.6.0

1.6.0.0 http://www.webiny.com/

Webiny Annotations Component

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sven Al Hamad
by Pavel Denisjuk

phpdoc annotations

29/09 2017

v1.6.1

1.6.1.0 http://www.webiny.com/

Webiny Annotations Component

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sven Al Hamad
by Pavel Denisjuk

phpdoc annotations

08/09 2017

1.5.x-dev

1.5.9999999.9999999-dev http://www.webiny.com/

Webiny Annotations Component

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sven Al Hamad
by Pavel Denisjuk

phpdoc annotations

08/09 2017

v1.5.0

1.5.0.0 http://www.webiny.com/

Webiny Annotations Component

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sven Al Hamad
by Pavel Denisjuk

phpdoc annotations

21/08 2016

1.4.x-dev

1.4.9999999.9999999-dev http://www.webiny.com/

Webiny Annotations Component

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sven Al Hamad
by Pavel Denisjuk

phpdoc annotations

21/08 2016

v1.4.3

1.4.3.0 http://www.webiny.com/

Webiny Annotations Component

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sven Al Hamad
by Pavel Denisjuk

phpdoc annotations

04/02 2016

v1.4.0

1.4.0.0 http://www.webiny.com/

Webiny Annotations Component

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sven Al Hamad
by Pavel Denisjuk

phpdoc annotations

04/02 2016

v1.4.1

1.4.1.0 http://www.webiny.com/

Webiny Annotations Component

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sven Al Hamad
by Pavel Denisjuk

phpdoc annotations

04/02 2016

v1.4.2

1.4.2.0 http://www.webiny.com/

Webiny Annotations Component

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sven Al Hamad
by Pavel Denisjuk

phpdoc annotations

16/03 2015

1.3.x-dev

1.3.9999999.9999999-dev http://www.webiny.com/

Webiny Annotations Component

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sven Al Hamad
by Pavel Denisjuk

phpdoc annotations

16/03 2015

v1.3.0

1.3.0.0 http://www.webiny.com/

Webiny Annotations Component

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sven Al Hamad
by Pavel Denisjuk

phpdoc annotations

15/02 2015

1.1.x-dev

1.1.9999999.9999999-dev http://www.webiny.com/

Webiny Annotations Component

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sven Al Hamad
by Pavel Denisjuk

annotations

05/02 2015

v1.2.2

1.2.2.0 http://www.webiny.com/

Webiny Annotations Component

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sven Al Hamad
by Pavel Denisjuk

phpdoc annotations

05/02 2015

v1.2.3

1.2.3.0 http://www.webiny.com/

Webiny Annotations Component

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sven Al Hamad
by Pavel Denisjuk

phpdoc annotations

04/02 2015

1.2.x-dev

1.2.9999999.9999999-dev http://www.webiny.com/

Webiny Annotations Component

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sven Al Hamad
by Pavel Denisjuk

phpdoc annotations

04/02 2015

v1.2.0

1.2.0.0 http://www.webiny.com/

Webiny Annotations Component

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sven Al Hamad
by Pavel Denisjuk

phpdoc annotations

04/02 2015

v1.2.1

1.2.1.0 http://www.webiny.com/

Webiny Annotations Component

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sven Al Hamad
by Pavel Denisjuk

phpdoc annotations

28/11 2014

v1.1.1

1.1.1.0 http://www.webiny.com/

Webiny Annotations Component

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sven Al Hamad
by Pavel Denisjuk

annotations

23/11 2014

v1.1.0

1.1.0.0 http://www.webiny.com/

Webiny Annotations Component

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sven Al Hamad
by Pavel Denisjuk

annotations

20/09 2014

1.0.x-dev

1.0.9999999.9999999-dev http://www.webiny.com/

Webiny Annotations Component

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sven Al Hamad
by Pavel Denisjuk

annotations

20/09 2014

v1.0.0

1.0.0.0 http://www.webiny.com/

Webiny Annotations Component

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sven Al Hamad
by Pavel Denisjuk

annotations