php

Symfony 2.8 Preps for Big Changes in Form Building Coming with Version 3.0

In the next major version of Symfony, version 3, there are lots of changes to the form building. These changes will require you to modify all of your existing form building code. The core of the change is the requirement that you use fully qualified class name when referencing the form element types. This change Symfony 2.8 Preps for Big Changes in Form Building Coming with Version 3.0

Symfony 2.8 Introduces the Range Form Element

The range form element is now available in Symfony 2.8. The range element is part of the HTML5 specification. In modern browsers, the range element is rendered as a slider. You can use it like this. $builder->add(‘volume’, ‘Symfony\Component\Form\Extension\Core\Type\RangeType’, [ ‘attr’ => [‘min’ => 0, ‘max’ => 11] ]); These go to eleven.

Handle XML Errors with PHP’s SimpleXMLElement

I don’t write procedural code any longer, so when I use PHP’s simple xml package, I use the object-oriented approach. Here’s how to handle, or suppress error/exceptions, when creating a SimpleXMLElement object. libxml_use_internal_errors(TRUE); // this turns off spitting errors on your screen try { $xml = new SimpleXMLElement($xmlStringOfData); } catch (Exception $e) { // Do Handle XML Errors with PHP’s SimpleXMLElement

Symfony Form Variables Reference

Here are the Symfony form variables. I’m posting it here because I find I often need to look at it and it’s easily to find here than in the Symfony documentation. Variable Usage form The current FormView instance. id The id HTML attribute to be rendered. name The name of the field (e.g. title) – Symfony Form Variables Reference

List of Symfony2 Exceptions

Symfony/Component/OptionsResolver/Exception/MissingOptionsException.php Symfony/Component/OptionsResolver/Exception/OptionDefinitionException.php Symfony/Component/OptionsResolver/Exception/InvalidOptionsException.php Symfony/Component/Serializer/Exception/InvalidArgumentException.php Symfony/Component/Serializer/Exception/UnsupportedException.php Symfony/Component/Serializer/Exception/UnexpectedValueException.php Symfony/Component/Serializer/Exception/LogicException.php Symfony/Component/Serializer/Exception/Exception.php Symfony/Component/Serializer/Exception/RuntimeException.php Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php Symfony/Component/HttpKernel/Exception/HttpException.php Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php Symfony/Component/HttpKernel/Exception/FlattenException.php Symfony/Component/Form/Exception/InvalidConfigurationException.php Symfony/Component/Form/Exception/TransformationFailedException.php Symfony/Component/Form/Exception/PropertyAccessDeniedException.php Symfony/Component/Form/Exception/TypeLoaderException.php Symfony/Component/Form/Exception/NotInitializedException.php Symfony/Component/Form/Exception/NotValidException.php Symfony/Component/Form/Exception/AlreadyBoundException.php Symfony/Component/Form/Exception/InvalidPropertyPathException.php Symfony/Component/Form/Exception/CreationException.php Symfony/Component/Form/Exception/StringCastException.php Symfony/Component/Form/Exception/FormException.php Symfony/Component/Form/Exception/TypeDefinitionException.php Symfony/Component/Form/Exception/UnexpectedTypeException.php Symfony/Component/Form/Exception/ErrorMappingException.php Symfony/Component/Form/Exception/InvalidPropertyException.php Symfony/Component/Process/Exception/ProcessFailedException.php Symfony/Component/Process/Exception/RuntimeException.php Symfony/Component/Yaml/Exception/DumpException.php Symfony/Component/Yaml/Exception/ParseException.php Symfony/Component/Filesystem/Exception/IOException.php Symfony/Component/HttpFoundation/File/Exception/AccessDeniedException.php Symfony/Component/HttpFoundation/File/Exception/FileNotFoundException.php Symfony/Component/HttpFoundation/File/Exception/UnexpectedTypeException.php Symfony/Component/HttpFoundation/File/Exception/UploadException.php Symfony/Component/HttpFoundation/File/Exception/FileException.php Symfony/Component/DependencyInjection/Exception/InvalidArgumentException.php Symfony/Component/DependencyInjection/Exception/ParameterNotFoundException.php Symfony/Component/DependencyInjection/Exception/LogicException.php Symfony/Component/DependencyInjection/Exception/OutOfBoundsException.php Symfony/Component/DependencyInjection/Exception/BadMethodCallException.php Symfony/Component/DependencyInjection/Exception/ServiceNotFoundException.php Symfony/Component/DependencyInjection/Exception/RuntimeException.php Symfony/Component/DependencyInjection/Exception/ServiceCircularReferenceException.php Symfony/Component/DependencyInjection/Exception/InactiveScopeException.php Symfony/Component/DependencyInjection/Exception/ParameterCircularReferenceException.php Symfony/Component/DependencyInjection/Exception/ScopeCrossingInjectionException.php Symfony/Component/DependencyInjection/Exception/ScopeWideningInjectionException.php Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php Symfony/Component/Config/Exception/FileLoaderLoadException.php Symfony/Component/Config/Definition/Exception/InvalidConfigurationException.php Symfony/Component/Config/Definition/Exception/ForbiddenOverwriteException.php List of Symfony2 Exceptions

PHPUnit –log-json is Broken, Here’s How to Fix It

For some reason, PHPUnit doesn’t produce valid Json when using the –log-json command-line option. The output looks like this. { “event”: “suiteStart”, “suite”: “TestAcme”, “tests”: 3 }{ “event”: “testStart”, “suite”: “TestAcme”, “test”: “TestAcme::testAcme1” }{ “event”: “test”, “suite”: “TestAcme”, “test”: “TestAcme::testAcme2”, “status”: “pass”, “time”: 1.85778188705, “trace”: [], “message”: “”, “output”: “t” }{ “event”: “testStart”, “suite”: “TestAcme”, PHPUnit –log-json is Broken, Here’s How to Fix It