我使用这种安装验证码束以下Instruction:使用验证码与Symfony2的(2.8)
- 添加
"gregwar/captcha-bundle": "1.0.0"
到require
部分中composer.json
- 运行
Windows PowerShell
在根和呼叫php composer.phar update
- 控制台输出
Warning: PHP Startup: Unable to load dynamic library 'C:\xampp\php\ext\php_yaml.dll' - Nie mo┐na odnalečŠ okreťlonego modu│u. in Unknown on line 0 Loading composer repositories with package information Updating dependencies (including require-dev) Nothing to install or update Generating autoload files Incenteev\ParameterHandler\ScriptHandler::buildParameters Updating the "app/config/parameters.yml" file Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
Warning: PHP Startup: Unable to load dynamic library 'C:\xampp\php\ext\php_yaml.dll' - Nie mo┐na odnalečŠ okreťlonego modu│u. in Unknown on line 0 Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
Warning: PHP Startup: Unable to load dynamic library 'C:\xampp\php\ext\php_yaml.dll' - Nie mo┐na odnalečŠ okreťlonego modu│u. in Unknown on line 0
// Clearing the cache for the dev environment with debug true
[OK] Cache for the "dev" environment (debug=true) was successfully cleared.
Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets
Warning: PHP Startup: Unable to load dynamic library 'C:\xampp\php\ext\php_yaml.dll' - Nie mo┐na odnalečŠ okreťlonego modu│u. in Unknown on line 0
Trying to install assets as relative symbolic links.
Bundle Method/Error
WARNING FrameworkBundle copy
WARNING JMSTranslationBundle copy! [NOTE] Some assets were installed via copy. If you make changes to these assets you have to run this command again.
[OK] All assets were successfully installed.
Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::prepareDeploymentTarget
下面的指令,我可以跳过这一步
// app/autoload.php $loader->registerNamspaces(array( // ... 'Gregwar' => __DIR__.'/../vendor/bundles', ));
但我autoload.php文件看起来如下:
use Doctrine\Common\Annotations\AnnotationRegistry;
use Composer\Autoload\ClassLoader;
error_reporting(error_reporting() & ~E_USER_DEPRECATED);
$loader = require __DIR__.'/../vendor/autoload.php';
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
return $loader;
我启用了捆绑:
// app/appKernel.php public function registerBundles() { $bundles = array( // ... new Gregwar\CaptchaBundle\GregwarCaptchaBundle(), ); }
最后安装步骤是将
gregwar_captcha: ~
添加到app/config/config.yml
并完成。
现在我试图在我的控制器中使用它。
public function registrationAction(Request $request)
{
$user = new Models\User();
$form = $this->createFormBuilder($user)
->add('username', 'Symfony\Component\Form\Extension\Core\Type\TextType')
->add('birth', 'Symfony\Component\Form\Extension\Core\Type\DateType')
->add('captcha', 'captcha')
->add('save', 'Symfony\Component\Form\Extension\Core\Type\SubmitType', array('label' => 'Register'))
->getForm();
$form->handleRequest($request);
return $this->render(
'CassyW2Bundle:User:registration.html.twig',
array(
'form' => $form->createView(),
)
);
}
我得到错误:
Compile Error: Declaration of Gregwar\CaptchaBundle\Type\CaptchaType::buildView() must be compatible with Symfony\Component\Form\FormTypeInterface::buildView(Symfony\Component\Form\FormView $view, Symfony\Component\Form\FormInterface $form, array $options)
哪儿了我错了吗?
我将版本更改为2.0.0并运行作曲家更新。它下载v1.1.1,但它的工作原理;-) – Bejkrools
正如我所看到的,你甚至不需要提供任何版本 - 在这种情况下(据我所知)来自master的最新提交将被克隆。 –