tonicospinelli / class-generation
Library to create Php Class files
2.2.1
2015-03-18 13:56 UTC
Requires
- php: >=5.3.3
- ext-reflection: *
Requires (Dev)
- ext-xdebug: *
- phpunit/phpunit: ~4.4
README
Introduction
When I developed a specific project, I saw an opportunity to create a library to generate Php Class Files and this library was born.
Installation
I assume you know about Composer, if not look at Composer WebSite.
$ php composer.phar require tonicospinelli/class-generation:2.2.*
OR
{ "tonicospinelli/class-generation" : "2.2.*" }
QUICK START
ClassGeneration is simple to use. Here's a sample for creating a Php Class File.
<?php require_once "../vendor/autoload.php"; use ClassGeneration\NamespaceClass; use ClassGeneration\PhpClass; use ClassGeneration\Property; use ClassGeneration\Writer; $code = new PhpClass(); $code ->setName('FirstClass') ->setNamespace(new NamespaceClass('MyNamespace')) ->setDescription('Class description') ->addProperty(new Property(array('name' => 'property'))) ->generateGettersAndSettersFromProperties(); $writer = new Writer(); $writer ->setPhpClass($code) ->setPath('./src') ->write();
Result: ./src/MyNamespace/FirstClass.php
<?php namespace MyNamespace; /** * Class description * @name FirstClass */ class FirstClass { public $property; public function getProperty() { return $this->property; } public function setProperty($property) { $this->property = $property; return $this; } }
Version
2.2
MIT License
Free Software, Hell Yeah!