Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixed out of sync code examples in getting-started.rst #759

Merged
merged 3 commits into from

3 participants

@mfdj

The inline cli-config.php, bootstrap.php examples were out of sync with Doctrine 2.4.x — I referenced https://github.com/doctrine/doctrine2-orm-tutorial/ for correct examples

@mfdj mfdj Update getting-started.rst
The inline cli-config.php, bootstrap.php examples were out of sync with Doctrine 2.4.x — I referenced https://github.com/doctrine/doctrine2-orm-tutorial/ for correct examples
3405659
@doctrinebot
Collaborator

Hello,

thank you for creating this pull request. I have automatically opened an issue
on our Jira Bug Tracker for you. See the issue link:

http://www.doctrine-project.org/jira/browse/DDC-2616

We use Jira to track the state of pull requests and the versions they got
included in.

docs/en/tutorials/getting-started.rst
@@ -186,8 +199,10 @@ doctrine command. Its a fairly simple file:
<?php
// cli-config.php
require_once "bootstrap.php";
-
- return \Doctrine\ORM\Tools\Console\ConsoleRunner::createHelperSet($entityManager);
@Ocramius Owner

2.4.x has the Doctrine\ORM\Tools\ConsoleRunner::createHelperSet() method.

@mfdj
mfdj added a note

My mistake, the version I was referring to was 2.3.4, which does not contain the method.

If I'm not mistaken according to packagist 2.3.4 is the newest stable, so anyone following directions to require (as the tutorial does) "doctrine/orm" : "2.*" will receive 2.3.4, and the cli-config.php will fail.

Perhaps the solution is to change the tutorial to require "2.4.*"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
docs/en/tutorials/getting-started.rst
((27 lines not shown))
// obtaining the entity manager
- $entityManager = EntityManager::create($conn, $config);
+ $entityManager = \Doctrine\ORM\EntityManager::create($conn, $config);
@Ocramius Owner

The leading backslash is not needed

@Ocramius Owner

The class is imported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
docs/en/tutorials/getting-started.rst
((12 lines not shown))
$isDevMode = true;
$config = Setup::createAnnotationMetadataConfiguration(array(__DIR__."/src"), $isDevMode);
- // or if you prefer yaml or XML
+ // or if you prefer yaml or annotations
@Ocramius Owner

This is wrong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
docs/en/tutorials/getting-started.rst
((7 lines not shown))
require_once "vendor/autoload.php";
-
- // Create a simple "default" Doctrine ORM configuration for Annotations
+
+ // Create a simple "default" Doctrine ORM configuration for XML Mapping
@Ocramius Owner

This tutorial uses annotations as far as I know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
docs/en/tutorials/getting-started.rst
@@ -131,25 +145,24 @@ step:
<?php
// bootstrap.php
use Doctrine\ORM\Tools\Setup;
- use Doctrine\ORM\EntityManager;
@Ocramius Owner

Why was this removed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
docs/en/tutorials/getting-started.rst
((29 lines not shown))
|-- composer.json
|-- config
| |-- xml
| `-- yaml
- `-- src
+ |-- src
+ `-- vendor
@Ocramius Owner

This is generated by composer. The end user shouldn't really bother

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
docs/en/tutorials/getting-started.rst
((11 lines not shown))
::
- project
+ doctrine2-tutorial
+ |-- composer.json
+ `-- vendor
@Ocramius Owner

No need for vendor, as it is handled by composer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@mfdj mfdj Updated require version and my earlier errors dissolved
As stated, the tutorial was written for 2.4.x, but the composer.json settings proffered would install 2.3.4, which has a different enough API that basic parts of the tutorial code would fail.
29366bb
@mfdj

@Ocramius made me realize that my problem was that I was using version 2.3.4, not 2.4.x as the tutorial assumes — so I updated the require statement and reverted many of my changes. Currently if someone were to composer require 2.* they would receive 2.3.4, since it's the newest stable on packagist.

@Ocramius Ocramius merged commit f634ba3 into doctrine:master

1 check passed

Details default The Travis CI build passed
@Ocramius
Owner

@mfdj just a note - can you eventually remove the minimum-stability flag once 2.4 is out?

@mfdj mfdj deleted the unknown repository branch
@mfdj

I'll do my best, although I'm not aware of Doctrine's release schedule and was just doing the tutorial to learn about how Doctrine2 works when isolated from Symfony2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 17, 2013
  1. @mfdj

    Update getting-started.rst

    mfdj authored
    The inline cli-config.php, bootstrap.php examples were out of sync with Doctrine 2.4.x — I referenced https://github.com/doctrine/doctrine2-orm-tutorial/ for correct examples
  2. @mfdj
Commits on Aug 18, 2013
  1. @mfdj

    Updated require version and my earlier errors dissolved

    mfdj authored
    As stated, the tutorial was written for 2.4.x, but the composer.json settings proffered would install 2.3.4, which has a different enough API that basic parts of the tutorial code would fail.
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 14 deletions.
  1. +14 −14 docs/en/tutorials/getting-started.rst
View
28 docs/en/tutorials/getting-started.rst
@@ -25,7 +25,7 @@ The code of this tutorial is `available on Github <https://github.com/doctrine/d
.. 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.
What is Doctrine?
@@ -87,14 +87,16 @@ the following contents:
{
"require": {
- "doctrine/orm": "2.*",
+ "doctrine/orm": "2.4.*",
"symfony/yaml": "2.*"
},
"autoload": {
"psr-0": {"": "src/"}
- }
+ },
+ "minimum-stability" : "dev"
}
+
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
This will install the packages Doctrine Common, Doctrine DBAL, Doctrine ORM,
-Symfony YAML and Symfony Console. Both Symfony dependencies are optional
-but will be used in this tutorial.
-
-You can prepare the directory structure:
+Symfony YAML and Symfony Console into the `vendor` directory. The Symfony
+dependencies are not required by Doctrine but will be used in this tutorial.
+Add the following directories:
::
- project
- |-- composer.json
+ doctrine2-tutorial
|-- config
| |-- xml
| `-- yaml
@@ -132,22 +132,22 @@ step:
// bootstrap.php
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
-
+
require_once "vendor/autoload.php";
-
+
// Create a simple "default" Doctrine ORM configuration for Annotations
$isDevMode = true;
$config = Setup::createAnnotationMetadataConfiguration(array(__DIR__."/src"), $isDevMode);
// or if you prefer yaml or XML
//$config = Setup::createXMLMetadataConfiguration(array(__DIR__."/config/xml"), $isDevMode);
//$config = Setup::createYAMLMetadataConfiguration(array(__DIR__."/config/yaml"), $isDevMode);
-
+
// database configuration parameters
$conn = array(
'driver' => 'pdo_sqlite',
'path' => __DIR__ . '/db.sqlite',
);
-
+
// obtaining the entity manager
$entityManager = EntityManager::create($conn, $config);
@@ -186,7 +186,7 @@ doctrine command. Its a fairly simple file:
<?php
// cli-config.php
require_once "bootstrap.php";
-
+
return \Doctrine\ORM\Tools\Console\ConsoleRunner::createHelperSet($entityManager);
You can then change into your project directory and call the
Something went wrong with that request. Please try again.