Skip to content

Instantly share code, notes, and snippets.

@raulghm
Created June 6, 2013 01:36
Show Gist options
  • Save raulghm/5718711 to your computer and use it in GitHub Desktop.
Save raulghm/5718711 to your computer and use it in GitHub Desktop.
Slim Framework + Eloquent ORM [Ultimate Solution] Thanks to: https://github.com/pyrocms/pyrocms/commit/7b7d92944f5de88fef9ec0b744289b924394a12e
{
"require": {
"slim/slim": "2.*",
"illuminate/database": "*",
"dhorrigan/capsule": "*"
}
}
<?php
require 'vendor/autoload.php';
$app = new \Slim\Slim();
use Illuminate\Database\Capsule\Manager as Capsule;
$capsule = new Capsule;
$capsule->addConnection(array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'database',
'username' => 'root',
'password' => '',
'prefix' => '',
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
));
$capsule->bootEloquent();
$capsule->setAsGlobal();
// Connect using the Laravel Database component
$conn = $capsule->connection();
use Illuminate\Database\Eloquent\Model as Model;
// Define models
class users extends Model {}
$app->get('/', function () use ($app) {
print_r( my_table::all() );
});
$app->run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment