Download the PHP package jan-swiecki/simple-annotations without Composer

On this page you can find all versions of the php package jan-swiecki/simple-annotations. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package simple-annotations

PHP Simple Annotations

Installation

Get composer and learn to use it.

Library is on packagist.

If you refuse to use composer then instead of include_once "vendor/autoload.php" use include_once "src/DocBlockReader/Reader.php".

Test

You need PHPUnit. After you get it run:

> git clone https://github.com/jan-swiecki/php-simple-annotations
> cd php-simple-annotations
> composer install
> phpunit

Introduction

This library gives you the ability to extract and auto-parse DocBlock comment blocks.

Example:

class TestClass {
  /**
   * @x 1
   * @y yes!
   */
  private $myVar;
}

$reader = new \DocBlockReader\Reader('TestClass', 'myVar', 'property');
$x = $reader->getParameter("x"); // 1 (with number type)
$y = $reader->getParameter("y"); // "yes!" (with string type)

So as you can see to do this you need to construct Reader object and target it at something. Then you extract data.

You can point at classes, class methods and class properties.

To extract parsed properties you have two methods:

API

Examples

Examples based on ReaderTest.php.

Note: DocBlock Reader converts type of values basing on the context (see below).

Type conversion example

will print

array (size=14)
  'var0' => float 1.5
  'var1' => int 1
  'var2' => string '123' (length=3)
  'var3' => string 'abc' (length=3)
  'var4' => 
    array (size=2)
      0 => string 'a' (length=1)
      1 => string 'b' (length=1)
  'var5' => 
    array (size=1)
      'x' => string 'y' (length=1)
  'var6' => 
    array (size=1)
      'x' => 
        array (size=1)
          'y' => string 'z' (length=1)
  'var7' => 
    array (size=1)
      'x' => 
        array (size=1)
          'y' => 
            array (size=2)
              0 => string 'z' (length=1)
              1 => string 'p' (length=1)
  'var8' => boolean true
  'var9' => null
  'var10' => boolean true
  'var11' => boolean true
  'var12' => boolean false
  'var13' => null

Multi value example

will print

array (size=3)
  'var' => string 'x' (length=1)
  'var2' => int 1024
  'param' => 
    array (size=3)
      0 => string 'string x' (length=8)
      1 => string 'integer y' (length=9)
      2 => string 'array z' (length=7)

Variables on the same line

will print

array (size=4)
  'get' => boolean true
  'post' => boolean true
  'ajax' => boolean true
  'postParam' => 
    array (size=3)
      0 => string 'x' (length=1)
      1 => string 'y' (length=1)
      2 => string 'z' (length=1)

Variable declarations functionality example

I found below functionality useful for filtering $_GET/$_POST data in CodeIgniter. Hopefully I will soon release my CodeIgniter's modification.

will print

array (size=2)
  0 => 
    array (size=2)
      'type' => string 'string' (length=6)
      'name' => string 'var1' (length=4)
  1 => 
    array (size=2)
      'type' => string 'integer' (length=7)
      'name' => string 'var2' (length=4)

All versions of simple-annotations with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package jan-swiecki/simple-annotations contains the following files

Loading the files please wait ....