PHP code example of codger / generate

1. Go to this page and download the library: Download codger/generate 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/ */

    

codger / generate example snippets




namespace Codger\MyNamespace;

use Codger\Generate\Recipe;

class MyRecipe extends Recipe
{
    public function __invoke()
    {
        // Do stuff...
    }
}



// ...
    $this->setTwigEnvironment($twig);
// ...



use Codger\Generate\Language;

echo Language::pluralize('city'); // cities
echo Language::singular('cities'); // city
echo Language::convert('Foo\Bar', Language::TYPE_CSS_IDENTIFIER); // foo-bar




$recipe->ask("What is your name?", function (string $answer) {
    $this->info("Hello, $answer.");
});



$recipe->options("Would you like fries with that?", ['Y' => 'Yes', 'n' => 'no'], function (string $answer) {
    if ($answer == 'Y') {
        $this->info('Yummy!');
    } else {
        $this->info('A very healthy choice.');
    }
});