PHP code example of jameslevi / silhouette

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

    

jameslevi / silhouette example snippets




use Graphite\Component\Silhouette\Config;



return [
  'enable'      => true,
  'port'        => 3306,
  'host'        => 'localhost',
  'username'    => 'root',
  'password'    => 'abcd',
  'database'    => 'users',
  'max-rows'    => 10000,
];

$db = new Config(__DIR__ . "/config/db.php");

$db->get('enable'); // This will return true.

$db->username; // This will return "root".

$db->add('charset', 'utf-8'); // This will add "charset" as new config data.

$db->set('database', 'photos'); // This will change the value of the key database.

$db->database = 'photos'; // This will change the value of database from "users" to "photos".

$db->has('password'); // Returns true.

$db->remove('enable'); // This will remove "enable" from your configuration object.

$db->toArray();

$db->toJson();

$db = new Config([
  'enable'      => true,
  'port'        => 3306,
  'host'        => 'localhost',
  'username'    => 'root',
  'password'    => 'abcd',
  'database'    => 'users',
  'max-rows'    => 10000,
]);



namespace App\Config;

use Graphite\Component\Silhouette\Facade;

class DB extends Facade
{
    public function __construct()
    {
        parent::__construct('config/db.php');
    }
}

DB::enable() // Returns the value of enable property.

DB::maxRows() // Returns the value 10000.

DB::enable(false) // Change the value of "enable" to false.

DB::context()->add('min_rows', 100); // This will add new configuration property.
DB::context()->set('min_rows', 110); // This will set the value of "min_rows".
DB::context()->remove('min-rows'); // This will remove "min_rows" from the data object.

// Create a new database configuration object.
$config = new Config(__DIR__ . '/config/db.php', true);

// You cannot add new data to your muted configuration.
$config->add('driver', 'mysql');



namespace App\Config;

use Graphite\Component\Silhouette\Facade;

class DB extends Facade
{
    public function __construct()
    {
        parent::__construct('config/db.php', true);
    }
}