GNKW Creator
Introduction
This creator is used to generate some PHP Classes in an organized structure. It use an autoloader, so you can easily call the classes you want between them and from a php main script by calling the autoloader. It also let you create PHPUnit test classes to test your php classes., (*1)
To use this Creator you need to have read and write rights to create files by PHP., (*2)
Install it with composer
To install composer :, (*3)
$ curl -sS https://getcomposer.org/installer | php
To install the latest version of the creator :, (*4)
Stable :, (*5)
$ php composer.phar create-project gnkw/creator gnkw-creator
Dev :, (*6)
$ php composer.phar create-project gnkw/creator gnkw-creator master
Go to your creator, (*7)
$ cd gnkw-creator
Update from 1.x to 2.x
This is the version 2.x of the creator, so now, you can't transform your classes and you can't use the old notation class like this : MyClass.class.php., (*8)
Please transform your classes with the standard notation : MyClass.php before updating the creator., (*9)
Create a class
You can create a class by using this command (replace Name/Space and MyClass by your datas) :, (*10)
$ php app/console.php create class Name/Space MyClass
Create a test class
To create a test class for a class using PHPUnit, it's a similar syntax :, (*11)
$ php app/console.php create test Name/Space MyClass
Note : If the original class don't exist, the test class can't be created., (*12)
Use a class
Copy the index.php
example file to your web directory, (*13)
$ mkdir web && cp examples/index.php web/.
After that, you want use your classes, so go to the web/index.php
file and use or precise the namespace in the Your Main Code section :, (*14)
$ vim web/index.php
~~~~~~~~~~~~~{.php}
/**
* Your Main Code
*/
use \Name\Space\MyClass;
$myClass = new MyClass();
~~~~~~~~~~~~~, (*15)
Then, when executing web/index.php
, it returns :, (*16)
$ php web/index.php
Hello MyClass !