Symfony 2 is programmatically tested using unit tests. You can read more about unit testing on Wikipedia.
Symfony 2 is hosted at a public GitHub repository: http://github.com/symfony/symfony
Basic information about working with Git can be found in the book Pro Git.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Entity.val.php | |
namespace Symfony\Components\Validator\Constraints; | |
$metadata->setGroupSequence(array('\Normal', '\Strict')); | |
$metadata->addPropertyConstraint('longitude', new NotNull(array('groups' => '\Strict'))); | |
$metadata->addPropertyConstraint('latitude', new Size(array('min' => 10))); | |
$metadata->addPropertyConstraint('latitude', new Size(array('max' => 1, 'groups' => '\Normal'))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Symfony\Components\Form\Form; | |
use Symfony\Components\Form\FieldGroup; | |
use Symfony\Components\Form\ChoiceField; | |
use Symfony\Components\Form\TextField; | |
use Symfony\Components\Form\CheckboxField; | |
use Symfony\Components\Form\NumberField; | |
use Symfony\Components\Form\PasswordField; | |
use Symfony\Components\Form\DoubleTextField; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Solution 1: | |
Constraints can be defined on the top level. | |
Advantages: | |
Little code | |
Disadvantage: | |
Min does not have a context. If multiple constraints of the same type exist, | |
they need to be wrapped in another annotation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Symfony\Foundation\UniversalClassLoader; | |
require_once __DIR__.'/src/Symfony/Foundation/UniversalClassLoader.php'; | |
$loader = new UniversalClassLoader(); | |
$loader->registerNamespace('Symfony', __DIR__.'/src'); | |
$loader->register(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
abstract class Configurable | |
{ | |
private $options = array(); | |
private $knownOptions = array(); | |
private $requiredOptions = array(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// avoid session starting for bots | |
$agents = array( | |
'googlebot', | |
'yahoo! slurp', | |
'baiduspider', | |
'sosospider', | |
'bingbot', | |
'nagios-plugins', | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class OptionSupport | |
{ | |
protected static $definitions = array(); | |
public static function getDefinition($class) | |
{ | |
if (!isset(self::$definitions[$class])) { | |
self::$definitions[$class] = new OptionDefinition($class); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class AuthorForm extends Form | |
{ | |
protected function configure() | |
{ | |
$this->setDataClass('Application\Entities\Author'); | |
// 1. problem | |
OlderNewer