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

Merged
merged 3 commits into from Aug 25, 2013

Conversation

Projects
None yet
3 participants
Contributor

mfdj commented Aug 17, 2013

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

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

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

Ocramius Aug 17, 2013

Owner

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

@mfdj

mfdj Aug 18, 2013

Contributor

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.*"

docs/en/tutorials/getting-started.rst
// obtaining the entity manager
- $entityManager = EntityManager::create($conn, $config);
+ $entityManager = \Doctrine\ORM\EntityManager::create($conn, $config);
@Ocramius

Ocramius Aug 17, 2013

Owner

The leading backslash is not needed

@Ocramius

Ocramius Aug 17, 2013

Owner

The class is imported

docs/en/tutorials/getting-started.rst
$isDevMode = true;
$config = Setup::createAnnotationMetadataConfiguration(array(__DIR__."/src"), $isDevMode);
- // or if you prefer yaml or XML
+ // or if you prefer yaml or annotations
@Ocramius

Ocramius Aug 17, 2013

Owner

This is wrong

docs/en/tutorials/getting-started.rst
-
- // Create a simple "default" Doctrine ORM configuration for Annotations
+
+ // Create a simple "default" Doctrine ORM configuration for XML Mapping
@Ocramius

Ocramius Aug 17, 2013

Owner

This tutorial uses annotations as far as I know

docs/en/tutorials/getting-started.rst
@@ -131,25 +145,24 @@ step:
<?php
// bootstrap.php
use Doctrine\ORM\Tools\Setup;
- use Doctrine\ORM\EntityManager;
@Ocramius

Ocramius Aug 17, 2013

Owner

Why was this removed?

docs/en/tutorials/getting-started.rst
|-- composer.json
|-- config
| |-- xml
| `-- yaml
- `-- src
+ |-- src
+ `-- vendor
@Ocramius

Ocramius Aug 17, 2013

Owner

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

docs/en/tutorials/getting-started.rst
- project
+ doctrine2-tutorial
+ |-- composer.json
+ `-- vendor
@Ocramius

Ocramius Aug 17, 2013

Owner

No need for vendor, as it is handled by composer

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.
Contributor

mfdj commented Aug 18, 2013

@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 added a commit that referenced this pull request Aug 25, 2013

Merge pull request #759 from mfdj/patch-1
Fixed out of sync code examples in getting-started.rst

@Ocramius Ocramius merged commit f634ba3 into doctrine:master Aug 25, 2013

1 check passed

default The Travis CI build passed
Details
Owner

Ocramius commented Aug 25, 2013

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

@mfdj mfdj deleted the mfdj:patch-1 branch Aug 26, 2013

Contributor

mfdj commented Aug 26, 2013

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