PHP code example of rougin / blueprint

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

    

rougin / blueprint example snippets

 php
// src/Commands/TestCommand.php

namespace Acme\Commands;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class TestCommand extends Command
{
    protected function configure()
    {
        $this->setName('test')->setDescription('Returns a "Test" string');
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $output->writeln('<info>Test</info>');
    }
}
 php
// bin/app.php

use Rougin\Blueprint\Blueprint;

// Return the root directory of the project ----------
$root = (string) __DIR__ . '/../../../../';

$exists = file_exists($root . '/vendor/autoload.php');

$root = $exists ? $root : __DIR__ . '/../';
// ---------------------------------------------------

 php
// src/Commands/TestCommand.php

namespace Acme\Commands;

use Rougin\Blueprint\Command;

class TestCommand extends Command
{
    protected $name = 'test';

    protected $description = 'Returns a "Test" string';

    public function execute()
    {
        $this->showPass('Test');
    }
}
 php
// src/Sample.php

namespace Acme;

class Sample
{
    protected $name;

    public function __construct($name)
    {
        $this->name = $name;
    }

    public function getName()
    {
        return $this->name;
    }
}
 php
namespace Acme\Commands;

use Acme\Sample;
use Rougin\Blueprint\Command;

class TextCommand extends Command
{
    protected $name = 'text';

    protected $description = 'Shows a sample text';

    protected $sample;

    public function __construct(Sample $sample)
    {
        $this->sample = $sample;
    }

    public function run()
    {
        $this->showText('Hello, ' . $this->sample->getName() . '!');

        return self::RETURN_SUCCESS;
    }
}
 bash
$ php bin/app.php text

Hello, Blueprint!