English 中文(简体)
Doctrine 2 - problems with "Getting Started XML-Edition" - generating database schema
原标题:

Having never touched Doctrine before (either 1 or 2), I am following this tutorial for Doctrine 2.

I m at the point where I use the command line to generate the database schema. This is the cli-config.php file, as per the tutorial:

<?php
$cliConfig = new DoctrineCommonCliConfiguration();
$cliConfig->setAttribute( em , $entityManager);

When I run it though, I just get an error:

Fatal error: require(): Failed opening required  DoctrineCommonCliConfiguration.php  

Because that class referenced by the cli-config.php file doesn t exist. I ve also tried blanking the cli-config.php file, which of course doesn t work either - says that "The helper "em" is not defined."

I m using version 2.0.0BETA3. I know that this is a beta version, so they could have changed some files around, but I can t find that class anywhere.

Any ideas on how to get it working?

最佳回答

The docs in the XML Getting Started are outdated in this regard. Please see the Tools section in the manual on how to configure the CLI Tool:

http://docs.doctrine-project.org/projects/doctrine-orm/en/2.0.x/reference/tools.html

All the rest still works as described. I will update this part asap.

问题回答

Assuming you installed Doctrine using pear

$ sudo pear install pear.doctrine-project.org/doctrineORM

which will install the three Doctrine 2 packages: DoctrineCommon, DoctrineDBAL, and DoctrineORM. On Ubuntu, these packages will be located in /usr/share/php/Doctrine, and the doctrine command line utility, will be installed into /usr/bin.

With this setup, this is a version of cli-config.php you can use (note: DIR should have two underscores before and after it. For some reason they didn t display).

<?php
require ‘Doctrine/ORM/Tools/Setup.php’;
// Setup Autoloader (1)
DoctrineORMToolsSetup::registerAutoloadPEAR();

require_once  Doctrine/Common/ClassLoader.php ;

$classLoader = new DoctrineCommonClassLoader( Entities , __DIR__); 

$classLoader->register();

$classLoader = new DoctrineCommonClassLoader( Proxies , __DIR__); 

$classLoader->register();

$config = new DoctrineORMConfiguration();

$config->setMetadataCacheImpl(new DoctrineCommonCacheArrayCache);

$driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__."/Entities"));

$config->setMetadataDriverImpl($driverImpl);

$config->setProxyDir(__DIR__ .  /Proxies );

$config->setProxyNamespace( Proxies );

$connectionOptions = array(
         driver  =>  pdo_mysql ,
         dbname  =>  bugs ,
         user  =>  bugs ,
         password  =>  xyzabc ,
   host  =>  localhost  );

$em = DoctrineORMEntityManager::create($connectionOptions, $config);

$helperSet = new SymfonyComponentConsoleHelperHelperSet(array(
     db  => new DoctrineDBALToolsConsoleHelperConnectionHelper($em->getConnection()),
     em  => new DoctrineORMToolsConsoleHelperEntityManagerHelper($em)
));




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签