2012-02-23 16 views
0
 I am studying namespace in php and **Doctrine 2.2** for a week. 
I explorered several blogs and read several articles about namespace in php. 
    And i understand that, when we want to use different namepaces in different php pages, 
we must write: include('php page that belong namespace we want to use'); 

    But Doctrine 2.2 doesn't use any include or require or require_once 
statements for using namespace. Almost all script in **Doctrine 2.2** like that : 

/*i am at Doctrine\ORM\EntityManager.php */ 

    **<?php 
    namespace Doctrine\ORM; 

use Closure, Exception, 
    Doctrine\Common\EventManager, 
    Doctrine\Common\Persistence\ObjectManager, 
    Doctrine\DBAL\Connection, 
    Doctrine\DBAL\LockMode, 
    Doctrine\ORM\Mapping\ClassMetadata, 
    Doctrine\ORM\Mapping\ClassMetadataFactory, 
    Doctrine\ORM\Query\ResultSetMapping, 
    Doctrine\ORM\Proxy\ProxyFactory, 
    Doctrine\ORM\Query\FilterCollection; 
class EntityManager implements ObjectManager 
{ 
    /** 
    * The used Configuration. 
    * 
    * @var \Doctrine\ORM\Configuration 
    ............. 
    .................................. 
    .................................. 
    .................................. 
    .................................. 
?>** 
    There isn't any include or require statement in **Doctrine 2.2**. 
But we run the page (Doctrine\ORM\EntityManager.php) appear fatal error, 

致命的なエラー: インターフェース '教義\共通\永続\のObjectManager' Cで 見つかりません:\ xamppの\ htdocsに\ WWW \ DoctrineExplained \ DoctrineORM教義\ \ ORM \ EntityManager.phpラインで45doctrine 2.2は、includeステートメントやrequireステートメントなしで、-namespace-and -use-を使用するのはなぜですか?

Although **Doctrine 2.2** is stable version of **Doctrine ORM**, 
why doesn't use include or require for --namespaces-- and --uses--? 

答えて

1

ほとんどのPHP 5.3のコードはそうです。 Doctrineは、あなたがそれを使い始める前にautoloadを設定することを期待しています。独自の__autoload()関数を定義したり、spl_register_autoload()を使用したり、そこにあるフレームワークの多くにバンドルされている実装を使用することができます。

これは、あまりにも長い間実行することができます。慣習が変更され、名前空間がその変更のためにプッシュされるまでにはちょうど時間がかかりました。

+0

私は、名前空間の文と慣習を変更することを表現したかったとします。ではない?もっと教えてください。 –

+0

何を知りたいですか?クラスを必要とすることはいつも面倒です。大量のインクルードにつながると、読み込みに多大なコードが必要になり、メモリの占有スペースが増加します。これを解決するためにオートロードが導入されました。 –

+0

お返事ありがとうございます。私はDoctrine ORMがすべてのページでincludeまたはrequireを使用しない理由を考えています。そして、あなたは理由を説明しました。私はこれまでに、(USE)声明が含まれているか、または必要としているように働いています。次は可能ですか? –

関連する問題