Merge pull request #759 from mfdj/patch-1
Fixed out of sync code examples in getting-started.rst
This commit is contained in:
commit
f634ba343c
@ -25,7 +25,7 @@ The code of this tutorial is `available on Github <https://github.com/doctrine/d
|
|||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
This tutorial assumes you work with Doctrine 2.4 and above.
|
This tutorial assumes you work with **Doctrine 2.4** and above.
|
||||||
Some of the code will not work with lower versions.
|
Some of the code will not work with lower versions.
|
||||||
|
|
||||||
What is Doctrine?
|
What is Doctrine?
|
||||||
@ -87,14 +87,16 @@ the following contents:
|
|||||||
|
|
||||||
{
|
{
|
||||||
"require": {
|
"require": {
|
||||||
"doctrine/orm": "2.*",
|
"doctrine/orm": "2.4.*",
|
||||||
"symfony/yaml": "2.*"
|
"symfony/yaml": "2.*"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-0": {"": "src/"}
|
"psr-0": {"": "src/"}
|
||||||
}
|
},
|
||||||
|
"minimum-stability" : "dev"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Install Doctrine using the Composer Dependency Management tool, by calling:
|
Install Doctrine using the Composer Dependency Management tool, by calling:
|
||||||
|
|
||||||
::
|
::
|
||||||
@ -102,15 +104,13 @@ Install Doctrine using the Composer Dependency Management tool, by calling:
|
|||||||
$ composer install
|
$ composer install
|
||||||
|
|
||||||
This will install the packages Doctrine Common, Doctrine DBAL, Doctrine ORM,
|
This will install the packages Doctrine Common, Doctrine DBAL, Doctrine ORM,
|
||||||
Symfony YAML and Symfony Console. Both Symfony dependencies are optional
|
Symfony YAML and Symfony Console into the `vendor` directory. The Symfony
|
||||||
but will be used in this tutorial.
|
dependencies are not required by Doctrine but will be used in this tutorial.
|
||||||
|
|
||||||
You can prepare the directory structure:
|
|
||||||
|
|
||||||
|
Add the following directories:
|
||||||
::
|
::
|
||||||
|
|
||||||
project
|
doctrine2-tutorial
|
||||||
|-- composer.json
|
|
||||||
|-- config
|
|-- config
|
||||||
| |-- xml
|
| |-- xml
|
||||||
| `-- yaml
|
| `-- yaml
|
||||||
@ -132,22 +132,22 @@ step:
|
|||||||
// bootstrap.php
|
// bootstrap.php
|
||||||
use Doctrine\ORM\Tools\Setup;
|
use Doctrine\ORM\Tools\Setup;
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
|
|
||||||
require_once "vendor/autoload.php";
|
require_once "vendor/autoload.php";
|
||||||
|
|
||||||
// Create a simple "default" Doctrine ORM configuration for Annotations
|
// Create a simple "default" Doctrine ORM configuration for Annotations
|
||||||
$isDevMode = true;
|
$isDevMode = true;
|
||||||
$config = Setup::createAnnotationMetadataConfiguration(array(__DIR__."/src"), $isDevMode);
|
$config = Setup::createAnnotationMetadataConfiguration(array(__DIR__."/src"), $isDevMode);
|
||||||
// or if you prefer yaml or XML
|
// or if you prefer yaml or XML
|
||||||
//$config = Setup::createXMLMetadataConfiguration(array(__DIR__."/config/xml"), $isDevMode);
|
//$config = Setup::createXMLMetadataConfiguration(array(__DIR__."/config/xml"), $isDevMode);
|
||||||
//$config = Setup::createYAMLMetadataConfiguration(array(__DIR__."/config/yaml"), $isDevMode);
|
//$config = Setup::createYAMLMetadataConfiguration(array(__DIR__."/config/yaml"), $isDevMode);
|
||||||
|
|
||||||
// database configuration parameters
|
// database configuration parameters
|
||||||
$conn = array(
|
$conn = array(
|
||||||
'driver' => 'pdo_sqlite',
|
'driver' => 'pdo_sqlite',
|
||||||
'path' => __DIR__ . '/db.sqlite',
|
'path' => __DIR__ . '/db.sqlite',
|
||||||
);
|
);
|
||||||
|
|
||||||
// obtaining the entity manager
|
// obtaining the entity manager
|
||||||
$entityManager = EntityManager::create($conn, $config);
|
$entityManager = EntityManager::create($conn, $config);
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ doctrine command. Its a fairly simple file:
|
|||||||
<?php
|
<?php
|
||||||
// cli-config.php
|
// cli-config.php
|
||||||
require_once "bootstrap.php";
|
require_once "bootstrap.php";
|
||||||
|
|
||||||
return \Doctrine\ORM\Tools\Console\ConsoleRunner::createHelperSet($entityManager);
|
return \Doctrine\ORM\Tools\Console\ConsoleRunner::createHelperSet($entityManager);
|
||||||
|
|
||||||
You can then change into your project directory and call the
|
You can then change into your project directory and call the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user