1. Go to this page and download the library: Download itsgoingd/slim-services 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/ */
itsgoingd / slim-services example snippets
use SlimServices\ServiceManager;
$app = new Slim\Slim(array(
// paths
'path' => __DIR__,
// database
'database.fetch' => PDO::FETCH_CLASS,
'database.default' => 'main',
'database.connections' => array(
'main' => array(
'driver' => 'mysql',
'host' => '127.0.0.1',
'database' => 'my_database',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
)
));
$services = new ServiceManager($app);
$services->registerServices(array(
'Illuminate\Events\EventServiceProvider',
'Illuminate\Database\DatabaseServiceProvider'
));
// Laravel database component is now available in Slim's DI container
$app->get('/users', function()
{
$app->render('users.html', array(
// Load user list using Laravel database fluent query builder
'users' => $app->db->table('users')->where('active', 1)->get()
));
})
$app->run();
use SlimServices\Service;
$app = new Slim(...);
$services = new ServiceManager($app);
$services->registerServices(array(
'Illuminate\Events\EventServiceProvider',
'Illuminate\Database\DatabaseServiceProvider',
'Illuminate\Filesystem\FilesystemServiceProvider',
'Illuminate\Translation\TranslationServiceProvider',
'Illuminate\Validation\ValidationServiceProvider',
'Mailer\MailerServiceProvider',
'Upload\UploadServiceProvider',
...
));