小编mag*_*tik的帖子

如何制作可执行的phar?

我想直接通过foo.phar <params>代替而开始将phar脚本作为可执行文件php foo.phar <params>.

php shebang phar

7
推荐指数
1
解决办法
5977
查看次数

Symfony2,Form,试图获取非对象的属性

我正在尝试创建一个没有实体的联系表单,但在我提交表单后,我会收到此错误:

Notice: Trying to get property of non-object in /var/www/Myblog/vendor/symfony/symfony/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php line 84
Run Code Online (Sandbox Code Playgroud)

这是我的 ContactType.php

<?php

namespace Acme\ContactBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Email;

class ContactType extends AbstractType
{
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => null,
            'csrf_protection' => true,
        ));
    }

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('name', 'text', array('constraints' => array(new NotBlank(array('message' => 'Name cannot be blank')), new Length(array('min' => 3, 'minMessage' => 'Name is too short')), 'label' => 'Name')))
                ->add('email', …
Run Code Online (Sandbox Code Playgroud)

php forms symfony

5
推荐指数
1
解决办法
4616
查看次数

静态属性继承CoffeeScript

让我们定义这个简单的代码:

class Foo
  @foo = 'blah'
  console.log(@foo)

class Bar extends Foo
  constructor: () ->
    console.log(@foo)

  bar: () ->
    console.log(@foo)

b = new Bar
b.bar()
Run Code Online (Sandbox Code Playgroud)

结果是:

blah
undefined
undefined
Run Code Online (Sandbox Code Playgroud)

如何@foo在继承的类中访问?

coffeescript

3
推荐指数
1
解决办法
1632
查看次数

标签 统计

php ×2

coffeescript ×1

forms ×1

phar ×1

shebang ×1

symfony ×1