Package Data | |
---|---|
Maintainer Username: | mcuadros |
Maintainer Contact: | mcuadros@gmail.com (Máximo Cuadros) |
Package Create Date: | 2013-05-17 |
Package Last Update: | 2013-07-02 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-22 03:04:55 |
Package Statistics | |
---|---|
Total Downloads: | 4 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 3 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Provider for using Mongator with Laravel 4 framework
Add mongator/laravel
to your composer requirements, you can see the package information on Packagist.:
{
"require": {
"mongator/laravel": "dev-master"
}
}
Now, run composer update
Once the package is installed, open your app/config/app.php
configuration file and locate the providers
key. Add the following line to the end:
...
'Mongator\Laravel\MongatorServiceProvider',
...
Next, locate the aliases
key and add the following lines:
...
'Mondator' => 'Mongator\Laravel\Facades\Mondator',
'Mongator' => 'Mongator\Laravel\Facades\Mongator',
...
Now just create a YAML config classes dir at your app
folder:
mkdir app/schema/
connection_dsn
(default 'mongodb://localhost:27017'): database connection stringconnection_database
: the database nameconnection_name
(default 'default'): the name of the connectionmodels_output
(default 'app/models/'): output path of the classesmodels_input
(default 'app/schema/'): A valid dir with YAML definitions of the config classesmetadata_class
: The metadata factory class namelogger
(default false): enable the query loggerextensions
(default Array()): array of extension instancesRoute::get('/view', function() {
$articleRepository = Mongator::getRepository('Article');
$article = $articleRepository->findOneById($id);
return View::make($article);
});
Route::get('/create', function() {
$article = Mongator::create('Article');
$article->setAuthor('John Doe');
$article->setTitle('Lorem ipsum dolor sit amet, consectetur adipisicing elit.')
$article->save();
});
Remember, before using the models you must generate them. (You can use the command provided with this package.)
With this package you can find three useful commands, thought php artisan
:
mongator:generate
: Processes config classes and generates the files of the classes.mongator:_indexes
: Ensures the indexes of all repositoriesmongator:fix
: Fixes all the missing references.Tests are in the tests
folder.
To run them, you need PHPUnit.
Example:
$ phpunit --configuration phpunit.xml.dist
MIT, see LICENSE