1. Go to this page and download the library: Download gm314/nitria library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gm314 / nitria example snippets
$classGenerator = new ClassGenerator("Generated\\MyClass", true);
// add extends statement, a use statement will be added automatically
$classGenerator->setExtends("BaseClass\\ClassName");
// add implement statement
$classGenerator->addImplements("\\Serializable");
// add a constant
$classGenerator->addConstant("CONSTANT_STRING", '"hello"');
// add property (for classes use statement will be added - unless the class is in the same namespace)
$classGenerator->addPrivateProperty("iAmPrivat", 'MyPackage\MyClass');
$classGenerator->addProtectedProperty("iAmProtected", "array", []);
$classGenerator->addPublicProperty("iAmPublic", "float");
$method = $classGenerator->addPublicMethod("myFunction");
$method->addParameter("string", "parameterName", '"defaultValue!"');
$method->addParameter("\\DateTime", "datetime");
// the method will have a return type string that is not nullable
$method->setReturnType("string", false);
$method->addCodeLine('return $parameterName;');