加載類型我使用FOSOAuthServerBundle
和Symfony
,我收到錯誤以下錯誤:無法symfony的
Could not load type "travel_oauth_server_auth"
500 Internal Server Error - Exception
這裏是我的service.xml
文件,因爲我是新來的Symfony,所以我不知道爲什麼我我得到這個錯誤。
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="travel_oauth_server.authorize.form_type" class="travel\HomeBundle\Form\Type\AuthorizeFormType">
</service>
<service id="travel_oauth_server.authorize.form" factory-method="createNamed" factory-service="form.factory" class="Symfony\Component\Form\Form">
<argument type="service" id="travel_oauth_server.authorize.form_type" />
<argument>%travel_oauth_server_auth%</argument>
</service>
<service id="travel_oauth_server.authorize.form_handler" class="travel\HomeBundle\Form\Handler\AuthorizeFormHandler" scope="request">
<argument type="service" id="travel_oauth_server.authorize.form" />
<argument type="service" id="request" />
<argument type="service" id="security.context" />
<argument type="service" id="fos_oauth_server.server" />
</service>
</services>
</container>
這裏是我創建AuthorizeFormType
形式:根據基準問題在配置文件中
<?php
namespace Travel\HomeBundle\Form\Type;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\AbstractType;
class AuthorizeFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('allowAccess', 'checkbox', array(
'label' => 'Allow access',
));
}
public function getDefaultOptions(array $options)
{
return array('data_class' => 'Travel\HomeBundle\Form\Model\Authorize');
}
public function getName()
{
return 'travel_oauth_server_authorize';
}
}
更新這可能是重複的,但我仍然得到同樣的錯誤
parameters:
travel_oauth_server_auth.class: Travel\HomeBundle\Form\Type\AuthorizeFormType
services:
travel_oauth_server_auth:
class: %travel_oauth_server_auth%
[Symfony2:無法加載類型「MyType」]的可能的副本 - (http://stackoverflow.com/questions/7218689/symfony2-could-not-load-type-mytype) - 當你剛接觸這個,期望的是你在問這個問題之前先研究這個問題。在處理常見的錯誤消息時,這是特別必要的,因爲這些消息很容易搜索。在您列出了迄今爲止已嘗試的內容並解釋了爲什麼所有這些嘗試都不起作用(參考現場的現有Q&A材料)之後,您可以創建一個問題。請通過編輯來詳細說明您現有的問題。 – hakre
@hakre對不起,但我不知道這個重複的問題將如何解決我的問題 – Hunt
那麼,那麼解釋一下,如果你打算嘗試它。否則,請先與其他相關資料聯繫。通常情況下,一條錯誤消息正在向您傳達某些信息,這是理解其內容的第一部分。在這種情況下,類型'travel_oauth_server_auth'保持未定義。它在代碼中定義在哪裏?這樣的ID也沒有服務。 – hakre