2017-11-06 12 views
0

後、私は通常私のコントローラを生成するために、自動ツールを使用していないが、私はそれが私の後に、しかしエラー自動生成CRUD

CRUD generation 


    created ./src/AppBundle/Controller//TransactionController.php 
    updated ./app/Resources/views/transaction/index.html.twig 
    updated ./app/Resources/views/transaction/show.html.twig 
    updated ./app/Resources/views/transaction/new.html.twig 
    updated ./app/Resources/views/transaction/edit.html.twig 
    created ./src/AppBundle/Tests/Controller/ 
    created ./src/AppBundle/Tests/Controller//TransactionControllerTest.php 
    created ./src/AppBundle/Resources/config/routing/ 
    created ./src/AppBundle/Resources/config/routing/transaction.php 
Generating the CRUD code: OK 
    created ./src/AppBundle/Form/ 
    created ./src/AppBundle/Form/TransactionType.php 
Generating the Form code: OK 
Updating the routing: Confirm automatic update of the Routing [yes]? yes 
Importing the CRUD routes: created ./src/AppBundle/Resources/config/routing.yml 
    updated ./app/config/routing.yml 
OK 


    Everything is OK! Now get to work :). 

を微走っ

php bin/console generate:doctrine:crud 

を実行してみたかったですコンポーザーパッケージをインストールしようとしましたが、これらのエラーが発生します。

[Symfony\Component\Config\Exception\FileLoaderLoadException]     
    The autoloader expected class "AppBundle\Resources\config\routing\transacti 
    on" to be defined in file "/Users/dash/AdvisorEngine/vendor/compos 
    er/../../src/AppBundle/Resources/config/routing/transaction.php". The file 
    was found but the class was not in it, the class name or namespace probably 
    has a typo in /Users/dash/AdvisorEngine/app/config/services.yml ( 
    which is being imported from "/Users/dash/AdvisorEngine/app/config 
    /config.yml").                



    [RuntimeException]               
    The autoloader expected class "AppBundle\Resources\config\routing\transacti 
    on" to be defined in file "/Users/dash/AdvisorEngine/vendor/compos 
    er/../../src/AppBundle/Resources/config/routing/transaction.php". The file 
    was found but the class was not in it, the class name or namespace probably 
    has a typo. 

設定/のrouting.yml

app: 
    resource: "@AppBundle/Resources/config/routing.yml" 
    prefix: /

AppBundle /リソース/設定/のrouting.yml

app_transaction: 
resource: "@AppBundle/Resources/config/routing/transaction.php" 
prefix: /transaction 

AppBundle /リソース/設定/ルーティング/ transaction.php

<?php 

use Symfony\Component\Routing\RouteCollection; 
use Symfony\Component\Routing\Route; 

$collection = new RouteCollection(); 

$collection->add('transaction_index', new Route(
    '/', 
    array('_controller' => 'AppBundle:Transaction:index'), 
    array(), 
    array(), 
    '', 
    array(), 
    array('GET') 
)); 

$collection->add('transaction_show', new Route(
    '/{id}/show', 
    array('_controller' => 'AppBundle:Transaction:show'), 
    array(), 
    array(), 
    '', 
    array(), 
    array('GET') 
)); 

$collection->add('transaction_new', new Route(
    '/new', 
    array('_controller' => 'AppBundle:Transaction:new'), 
    array(), 
    array(), 
    '', 
    array(), 
    array('GET', 'POST') 
)); 

$collection->add('transaction_edit', new Route(
    '/{id}/edit', 
    array('_controller' => 'AppBundle:Transaction:edit'), 
    array(), 
    array(), 
    '', 
    array(), 
    array('GET', 'POST') 
)); 

$collection->add('transaction_delete', new Route(
    '/{id}/delete', 
    array('_controller' => 'AppBundle:Transaction:delete'), 
    array(), 
    array(), 
    '', 
    array(), 
    array('DELETE') 
)); 

return $collection; 

AppBundle:Transacti on

<?php 
namespace AppBundle\Entity; 

use Doctrine\ORM\Mapping as ORM; 

/** 
* @ORM\Entity 
* @ORM\Table(name="transactions") 
*/ 
class Transaction 
{ 
    const OPERATION_BUY = 'buy'; 
    const OPERATION_SELL = 'sell'; 

    /** 
    * @ORM\Id 
    * @ORM\Column(type="integer") 
    * @ORM\GeneratedValue(strategy="AUTO") 
    */ 
    private $id; 

    /** 
    * @ORM\Column(type="date") 
    */ 
    private $date; 

    /** 
    * @ORM\ManyToOne(targetEntity="Stock") 
    * @ORM\JoinColumn(name="stock_id", referencedColumnName="id") 
    */ 
    private $stock; 

    /** @ORM\Column(type="string") */ 
    private $operation; 

    /** 
    * @ORM\Column(type="integer") 
    */ 
    private $amount; 

    /** 
    * @ORM\Column(type="decimal", precision=7, scale=2) 
    */ 
    private $unitPrice; 

    /** 
    * @ORM\Column(type="decimal", precision=10, scale=2) 
    */ 
    private $price; 

    /** 
    * @return mixed 
    */ 
    public function getId() 
    { 
     return $this->id; 
    } 

    /** 
    * @param mixed $id 
    */ 
    public function setId($id) 
    { 
     $this->id = $id; 
    } 

    /** 
    * @return mixed 
    */ 
    public function getDate() 
    { 
     return $this->date; 
    } 

    /** 
    * @param mixed $date 
    */ 
    public function setDate($date) 
    { 
     $this->date = $date; 
    } 

    /** 
    * @return mixed 
    */ 
    public function getStock() 
    { 
     return $this->stock; 
    } 

    /** 
    * @param mixed $stock 
    */ 
    public function setStock($stock) 
    { 
     $this->stock = $stock; 
    } 

    /** 
    * @return mixed 
    */ 
    public function getamount() 
    { 
     return $this->amount; 
    } 

    /** 
    * @param mixed $amount 
    */ 
    public function setamount($amount) 
    { 
     $this->amount = $amount; 
    } 

    /** 
    * @return mixed 
    */ 
    public function getUnitPrice() 
    { 
     return $this->unitPrice; 
    } 

    /** 
    * @param mixed $unitPrice 
    */ 
    public function setUnitPrice($unitPrice) 
    { 
     $this->unitPrice = $unitPrice; 
    } 

    /** 
    * @return mixed 
    */ 
    public function getPrice() 
    { 
     return $this->price; 
    } 

    /** 
    * @param mixed $price 
    */ 
    public function setPrice($price) 
    { 
     $this->price = $price; 
    } 

    /** 
    * @return mixed 
    */ 
    public function getOperation() 
    { 
     return $this->operation; 
    } 

    /** 
    * @param string $operation 
    */ 
    public function setOperation($operation) 
    { 
     if (!in_array($operation, [ self::OPERATION_BUY, self::OPERATION_SELL])) { 
      $this->operation = $operation; 
     } 
    } 
} 

ルーティングからクラスを期待しているのはなぜですか?この行に基づいて

答えて

1

created ./src/AppBundle/Resources/config/routing/transaction.php 

私はあなたのコード内のどこかにtransaction.phpのための適切なパスを定義していない、とCRUDジェネレータは間違った場所にこのファイルを構築していると思われます。

+0

少し詳しく説明できますか?これはsymfonyの新規インストールです。私はすべての基本(データベース、メーラー)を設定しました。 それ以外は、何も変更/設定していません。 – Bernardo

+0

あなたはどのsymfonyのバージョンを使用していますか?ルーティングymlファイルを共有できますか? – mpilliador

+0

実際には、あなたが生き残っているエンティティを共有することはできますか? – mpilliador