MySQL
this is very very simple. Open the "/<project folder>/app/config/parameters.yml" and provide the appropriate values. this is my values
parameters:
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: ~
database_name: kanasblog
database_user: root
database_password: ~
then go to the project folder and execute the fallowing command
$ php app/console doctrine:database:create
oh wait. i forgot to tell something. in php there two most popular ORM frameworks available. Doctrine and Propel . both frameworks can be used with Symfony2 very easily. in here i used Doctrine and it will install automatically. If it is not doctrine bundle can be be added using composer.
mongodb
Actually this is bit tufter to install than mysql. First of all php mongodb extension should be installed to php(both command line and working php).
then update php.ini file by including "extension=mongo.so". to find the ini file location
$ php -i |grep php\.ini
Ok, let's install mongodb bundle usong composer. So we have to update the "composer.json" file. include fallowing to "require" dictionary.
"doctrine/mongodb-odm": "1.0.*@dev",
"doctrine/mongodb-odm-bundle": "3.0.*@dev"
then update
$ php composer.phar update
now we have to do two more things. register notation and driver..
to register annotation open the "app/autoload.php" file and insert fallowing content just below the "AnnotationRegistry::registerLoader(array($loader, 'loadClass'));" line
use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver;
AnnotationDriver::registerAnnotationClasses();
to register bundle open the "/app/AppKernel.php" file and add fallowing to "$bundle" array
new Doctrine\Bundle\MongoDBBundle\DoctrineMongoDBBundle(),
finaly set database parameters for mongodb. open the "/app/config/config.yml"
and add fallowing
doctrine_mongodb:
connections:
default:
server: mongodb://localhost:27017
options: {}
default_database: samitiya
document_managers:
default:
auto_mapping: true
thats it. execute fallowing in the terminal.
$ php app/console doctrine:mongodb:schema:create
for more information visit page DoctrineMongoDBBundle
No comments:
Post a Comment