Symfony2 cached controller won’t update

I’m quite new to PHP and have received some Symfony2 project to maintain. Now I’ve found out that when I update foo.html.twig, that page will not change until I perform the command console c:c -e prod. Until then the shown page will be foo.html_.twig (hence the underscore).

The problem is that I’ve changed a controller, let’s say BarController.php, but the new added value in that controller does not work in the .twig file, I think because the BarController_.php did not get updated with the clear cache command. What did I do wrong here?


Source: stackoverflow-php

Symfony form event, change value on radio button

I have form for OutboundInvoice entity, in form I have customer choice field, with query_builder and when select customer I need change select data in radio button in field invoicingType. How can how to do it ?

Now I using symfony form event for change label for 'mapped' => false, field in form and I think this is close decision, bгt how correct realized I don’t know

class OutboundInvoiceForm extends AbstractType
{
/**
 * @param FormBuilderInterface $builder
 * @param array $options
 */
public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ->add('customer', 'entity', array(
            'class' => Customer::class,
            'property' => 'name',
            'empty_value' => 'Choice Customer',
            'query_builder' => function ($repository) {
                /** @var CustomerRepository $repository */
                return $repository->getAllQuery();
            },
            'required' => true
        ));

    $formModifier = function (FormInterface $form, Customer $customer = null) {
        if (null === $customer) {
            $positions = '-';
            $label = $positions;
        } else {
            $positions = $customer->getInvoicingAddress()
                ? $customer->getInvoicingAddress()->getFormattedAddress()
                : '-';
            $label = $positions;
        }

        $form
            ->add('invoicing_address', TextType::class, [
                'mapped' => false,
                'empty_data' => $positions,
                'label' => $label
            ]);

    };

    $builder->addEventListener(
        FormEvents::PRE_SET_DATA,
        function (FormEvent $event) use ($formModifier) {
            $data = $event->getData();
            $formModifier($event->getForm(), $data->getCustomer());
        }
    );

    $builder->get('customer')->addEventListener(
        FormEvents::POST_SUBMIT,
        function (FormEvent $event) use ($formModifier) {
            $customer = $event->getForm()->getData();
            $formModifier($event->getForm()->getParent(), $customer);
        }
    );
    $builder
        ->add('invoicingType', 'entity', array(
            'class' => InvoicingType::class,
            'property' => 'name',
            'query_builder' => function ($repository) {
                /** @var InvoicingTypeRepository $repository */
                return $repository->getAllQuery();
            },
            'required' => false,
            'expanded' => true,
        ))
        ->add('message')
        ->add('notes');
}

/**
 * @param OptionsResolverInterface $resolver
 */
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
    $resolver->setDefaults(array(
        'data_class' => OutboundInvoice::class,
        'csrf_protection' => false,
        'edit' => false,
        'terms_edit_data' => 0
    ));
}

/**
 * @return string
 */
public function getName()
{
    return 'economy_bundle_outbound_invoice';
}

this my js where replaced html with by element

var $customer = $('#economy_bundle_outbound_invoice_customer');

$customer.change(function() {   
var $form = $(this).closest('form');
var data = {};
data[$sport.attr('name')] = $sport.val();
$.ajax({
    url : $form.attr('action'),
    type: $form.attr('method'),
    data : data,
    success: function(html) {
        $('#invoicing-address-container').replaceWith(
            $(html).find('#invoicing-address-container')
        );
    }
});
});


Source: stackoverflow-php

Error: mssql_connect(): Unable to connect to server:

What could be the problem that some of the cron functions which always connects to the database using the code below suddenly started to fail?

It seems that it can’t connect to DB. Credentials are good, they didn’t changed. TestConnect is a class which is called then I want to connect to my DB. I use it like this :

$test = new TestConnect(true);

Now the class file is found and it is working as far as I understand.

class TestConnect
{

private $_server = 'test';
private $_username = 'test';
private $_password = 'password';
private $_database = 'database';
private $_query = null;
private $_handle = null;
private $_handle_db = null;
private $_result = null;

public function __construct($connect = null, $query = null)
{
    if ($connect)
    {
        $this->connect();
    }

    if ($query)
    {
        $this->query($query);
    }
}

public function connect()
{
    ini_set('memory_limit','1024M');
    putenv("FREETDSCONF=/etc/freetds.conf");

    if ($this->_handle)
    {
        return $this->_handle;
    }
    else
    {
        if ( ! $this->_handle = mssql_connect($this->_server, $this->_username, $this->_password))
        {
            throw new Exception($this->get_error_message());
        }

        if ( ! $this->_handle_db = mssql_select_db($this->_database, $this->_handle))
        {
            throw new Exception($this->get_error_message());
        }
    }
}
}


Source: stackoverflow-php