PHP code example of rougin / basilisk

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

 bash
$ cd hogwarts
$ php setup.php
 php
// app/config/app.php

return array(

    // ...

    'name' => getenv('APP_NAME'), // returns "Basilisk"

    // ...

    'version' => getenv('APP_VERSION'), // returns "0.1.0"

    // ...

);
 php
// app/config/phinx.php

return array(

    /**
     * Paths to be used for database migration.
     *
     * @var array<string, string[]>
     */
    'paths' => array(

        /**
         * @var array
         */
        'migrations' => array(
            $root . '/src/Phinx/Scripts',
        ),

        /**
         * @var array
         */
        'seeds' => array(
            $root . '/src/Phinx/Seeders',
        ),

    ),

    // ...

);
 php
namespace App\Depots;

use App\Models\User;

class UserDepot
{
    /**
     * @var \App\Models\User
     */
    protected $user;

    /**
     * @param \App\Models\User $user
     */
    public function __construct(User $user)
    {
        $this->user = $user;
    }

    /**
     * @return array<string, mixed>[]
     */
    public function all()
    {
        $result = $this->user->all();

        $items = array();

        // ...

        return $items;
    }
}
 php
// src/Phinx/Scripts/20171012020230_create_users_table.php

use Phinx\Migration\AbstractMigration;

class CreateUsersTable extends AbstractMigration
{
    public function change(): void
    {
        $properties = ['id' => false, 'primary_key' => ['id']];

        $table = $this->table('users', $properties);

        $table->addColumn('id', 'integer', ['limit' => 10, 'identity' => true]);
        $table->addColumn('name', 'string', ['limit' => 200]);
        $table->addColumn('email', 'string', ['limit' => 200]);
        $table->addColumn('password', 'string', ['limit' => 500]);
        $table->addColumn('created_at', 'datetime');
        $table->addColumn('updated_at', 'datetime', ['null' => true]);

        $table->create();
    }
}
 php
// src/Phinx/Seeders/UserSeeder.php

use Phinx\Seed\AbstractSeed;

class UserSeeder extends AbstractSeed
{
    protected $items =
    [
        ['name' => 'Harry Jonathans Potter', 'email' => '[email protected]'],
        ['name' => 'Hermione Jane Granger', 'email' => '[email protected]'],
        ['name' => 'Ronald Bilius Weasley', 'email' => '[email protected]'],
    ];

    public function run(): void
    {
        $data = array();

        foreach ($this->items as $item)
        {
            $item['created_at'] = date('Y-m-d H:i:s');

            $data[] = $item;
        }

        $this->table('users')->insert($data)->save();
    }
}
 php
namespace App\Routes;

use Rougin\Slytherin\Template\RendererInterface;

class Hello
{
    /**
     * Returns the "Hello, Muggle!" text.
     *
     * @return string
     */
    public function index(RendererInterface $renderer)
    {
        return $renderer->render('index');
    }
}
 php
namespace App;

use Rougin\Slytherin\Routing\Router as Slytherin;

class Router extends Slytherin
{
    /**
     * @var string
     */
    protected $namespace = 'App\Routes';

    /**
     * @var string
     */
    protected $prefix = '/';

    /**
     * @return \Rougin\Slytherin\Routing\RouteInterface[]
     */
    public function routes()
    {
        $this->get('/', 'Hello@index');

        // ...

        return $this->routes;
    }
}
 php
// src/Scripts/HelloWorld.php

echo 'Hello world!';
 bash
$ php src/Scripts/HelloWorld.php

Hello world!
 bash
$ composer global 
 bash
$ php-cs-fixer fix --config=phpstyle.php