2016-01-27 15 views
1

我使用这种安装验证码束以下Instruction使用验证码与Symfony2的(2.8)

  1. 添加"gregwar/captcha-bundle": "1.0.0"require部分中composer.json
  2. 运行Windows PowerShell在根和呼叫php composer.phar update
  3. 控制台输出

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

  1. 下面的指令,我可以跳过这一步

    // 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) 
    

    哪儿了我错了吗?

    回答

    1

    请参阅Doc。对于你的symfony版本,你需要这个包的另一个版本。尝试在不提供版本composer.json的情况下安装它。

    +0

    我将版本更改为2.0.0并运行作曲家更新。它下载v1.1.1,但它的工作原理;-) – Bejkrools

    +0

    正如我所看到的,你甚至不需要提供任何版本 - 在这种情况下(据我所知)来自master的最新提交将被克隆。 –

    0

    根据警告,尝试通过从PEAR的sitweb https://pecl.php.net/package/yaml下载此安装php_yaml扩展。

    选择稳定的版本,并复制该dll提取时** C:\ XAMPP \ PHP \分机**

    +0

    感谢:-)相信我,我已经尝试了这个dll文件的所有可能的版本。每当我在控制台中调用“php”时会显示此警告,但YAML正常工作。任何想法为什么? – Bejkrools