Created
June 6, 2013 01:36
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"require": { | |
"slim/slim": "2.*", | |
"illuminate/database": "*", | |
"dhorrigan/capsule": "*" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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