PHP code example of samagtech / bit-framework

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

    

samagtech / bit-framework example snippets





ef\Context\Context;

class Handler implements \Bref\Event\Handler
{
    public function handle($event, Context $context)
    {
        return 'Hello ' . $event['name'];
    }
}



// bootstrap.php



use SamagTech\BitFramework\Application;



// $app->register(Provider::class) Funzione per registrare dei provider

// $app->bootDb() Da utilizzare nel caso di DB

return $app;


// index.php

try {

    $app = ndler::class);

    return $app->run();

}
catch (Error|Exception $e) {

    log_message('error', $e->getMessage(), ['exception' => $e]);
}


// FooProvider.php

class FooProvider implements \SamagTech\BitFramework\Contracts\Provider {

    public function register () : void {

        app()->bind(Foo::class, new Foo());

        // Or

        app()->bind(Foo::class, function () {
            return new Foo();
        })
    }
}


class Foo extends Illuminate\Database\Eloquent\Model {}




return [
    'default'   => [
        'driver'    => env('DB_DRIVER', 'mysql'),
        'host'      => env('DB_HOST', '127.0.0.1'),
        'database'  => env('DB_NAME', ''),
        'username'  => env('DB_USER', ''),
        'password'  => env('DB_PASSWORD', ''),
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => env('DB_PREFIX', ''),
        'port'      => env('DB_PORT', '3306'),
    ]

];