From d3fe07b1600f50c0b0f926317c3bb01cab21cdfb Mon Sep 17 00:00:00 2001 From: Roy Van Ginneken Date: Sun, 11 Oct 2015 14:15:29 +0200 Subject: [PATCH 01/12] [TwigBundle] fixed Include file locations in "Template could not be found" exception --- src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php index 65afe2a33e..faf5ce3217 100644 --- a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php +++ b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php @@ -89,7 +89,10 @@ class FilesystemLoader extends \Twig_Loader_Filesystem } if (false === $file || null === $file) { - throw new \Twig_Error_Loader(sprintf('Unable to find template "%s".', $logicalName), -1, null, $previous); + list($namespace, $name) = $this->parseName($logicalName); + $paths = $this->getPaths($namespace); + array_walk($paths, function (&$path) use ($name) { $path .= '/' . $name; }); + throw new \Twig_Error_Loader(sprintf('Unable to find template "%s" (tried: %s).', $name, implode(', ', $paths)), -1, null, $previous); } return $this->cache[$logicalName] = $file; From e9d951a8821df4df3fcce48ec79806cca97dbae7 Mon Sep 17 00:00:00 2001 From: Roy Van Ginneken Date: Sun, 11 Oct 2015 14:34:15 +0200 Subject: [PATCH 02/12] [CodingStandards] Conformed to coding standards --- src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php index faf5ce3217..73e38cbe86 100644 --- a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php +++ b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php @@ -91,7 +91,7 @@ class FilesystemLoader extends \Twig_Loader_Filesystem if (false === $file || null === $file) { list($namespace, $name) = $this->parseName($logicalName); $paths = $this->getPaths($namespace); - array_walk($paths, function (&$path) use ($name) { $path .= '/' . $name; }); + array_walk($paths, function (&$path) use ($name) { $path .= '/'.$name; }); throw new \Twig_Error_Loader(sprintf('Unable to find template "%s" (tried: %s).', $name, implode(', ', $paths)), -1, null, $previous); } From 968476b707c75caf517519a47d8385d4dc23ec05 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 19 Jan 2016 09:57:11 +0100 Subject: [PATCH 03/12] Improved the error message when a template is not found --- .../Bundle/TwigBundle/Loader/FilesystemLoader.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php index 73e38cbe86..8b9f47b4de 100644 --- a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php +++ b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php @@ -89,10 +89,14 @@ class FilesystemLoader extends \Twig_Loader_Filesystem } if (false === $file || null === $file) { - list($namespace, $name) = $this->parseName($logicalName); - $paths = $this->getPaths($namespace); - array_walk($paths, function (&$path) use ($name) { $path .= '/'.$name; }); - throw new \Twig_Error_Loader(sprintf('Unable to find template "%s" (tried: %s).', $name, implode(', ', $paths)), -1, null, $previous); + try { + list($namespace, $name) = $this->parseName($logicalName); + $paths = sprintf(' (looked into: %s)', implode(', ', $this->getPaths($namespace)));; + } catch (\Twig_Error_Loader $e) { + $paths = ''; + } + + throw new \Twig_Error_Loader(sprintf('Unable to find template "%s"%s.', $name, $paths, -1, null, $previous)); } return $this->cache[$logicalName] = $file; From 35f082f6ef954b78af20e36f8b1bae7d32dda83d Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 19 Jan 2016 10:10:19 +0100 Subject: [PATCH 04/12] Fixed a syntax issue --- src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php index 8b9f47b4de..0bc4bc5583 100644 --- a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php +++ b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php @@ -91,7 +91,7 @@ class FilesystemLoader extends \Twig_Loader_Filesystem if (false === $file || null === $file) { try { list($namespace, $name) = $this->parseName($logicalName); - $paths = sprintf(' (looked into: %s)', implode(', ', $this->getPaths($namespace)));; + $paths = sprintf(' (looked into: %s)', implode(', ', $this->getPaths($namespace))); } catch (\Twig_Error_Loader $e) { $paths = ''; } From 88b913b0c465dd805d679a0642aba4fd17a20241 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 27 Jan 2016 17:49:58 +0100 Subject: [PATCH 05/12] Fixed the problem in an easier way --- .../Bundle/TwigBundle/Loader/FilesystemLoader.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php index 0bc4bc5583..e3170aff94 100644 --- a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php +++ b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php @@ -78,6 +78,7 @@ class FilesystemLoader extends \Twig_Loader_Filesystem $file = parent::findTemplate($logicalName); } catch (\Twig_Error_Loader $e) { $previous = $e; + $errorMessage = $e->getMessage(); // for BC try { @@ -89,14 +90,7 @@ class FilesystemLoader extends \Twig_Loader_Filesystem } if (false === $file || null === $file) { - try { - list($namespace, $name) = $this->parseName($logicalName); - $paths = sprintf(' (looked into: %s)', implode(', ', $this->getPaths($namespace))); - } catch (\Twig_Error_Loader $e) { - $paths = ''; - } - - throw new \Twig_Error_Loader(sprintf('Unable to find template "%s"%s.', $name, $paths, -1, null, $previous)); + throw new \Twig_Error_Loader($errorMessage, -1, null, $previous); } return $this->cache[$logicalName] = $file; From 19bfa2ed8c4c216ed827670ed53e1aa408a3a00d Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 27 Jan 2016 18:13:21 +0100 Subject: [PATCH 06/12] Added a test --- .../Tests/Loader/FilesystemLoaderTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php index 3fd0888cda..cc993c7527 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php @@ -98,4 +98,21 @@ class FilesystemLoaderTest extends TestCase $loader = new FilesystemLoader($locator, $parser); $loader->getCacheKey('name.format.engine'); } + + /** + * @expectedException \Twig_Error_Loader + * @expectedExceptionMessageRegExp /Unable to find template "name\.format\.engine" \(looked into: .*\/Tests\/Loader\/\.\.\/DependencyInjection\/Fixtures\/Resources\/views\)/ + */ + public function testTwigErrorIfTemplateDoesNotExist() + { + $parser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface'); + $locator = $this->getMock('Symfony\Component\Config\FileLocatorInterface'); + + $loader = new FilesystemLoader($locator, $parser); + $loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/Resources/views'); + + $method = new \ReflectionMethod('Symfony\Bundle\TwigBundle\Loader\FilesystemLoader', 'findTemplate'); + $method->setAccessible(true); + $method->invoke($loader, 'name.format.engine'); + } } From 0134d7678516f6c9ec56059e0596685c501724b4 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 1 Mar 2016 15:47:09 +0100 Subject: [PATCH 07/12] Simplified everything --- src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php index e3170aff94..2a21c30fba 100644 --- a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php +++ b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php @@ -77,20 +77,18 @@ class FilesystemLoader extends \Twig_Loader_Filesystem try { $file = parent::findTemplate($logicalName); } catch (\Twig_Error_Loader $e) { - $previous = $e; - $errorMessage = $e->getMessage(); + $twigLoaderException = $e; // for BC try { $template = $this->parser->parse($template); $file = $this->locator->locate($template); } catch (\Exception $e) { - $previous = $e; } } if (false === $file || null === $file) { - throw new \Twig_Error_Loader($errorMessage, -1, null, $previous); + throw $twigLoaderException; } return $this->cache[$logicalName] = $file; From c3744202f60aa617135238acc51232c98dcbb6e4 Mon Sep 17 00:00:00 2001 From: Craig Menning Date: Thu, 28 Jan 2016 13:26:57 -0600 Subject: [PATCH 08/12] Remove _path from query parameters when fragment is a subrequest and request attributes are already set Added tests for _path removal in FragmentListener --- .../EventListener/FragmentListener.php | 9 ++++++- .../EventListener/FragmentListenerTest.php | 25 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php b/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php index 04193aadd2..7b5dfb0119 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php @@ -58,7 +58,14 @@ class FragmentListener implements EventSubscriberInterface { $request = $event->getRequest(); - if ($request->attributes->has('_controller') || $this->fragmentPath !== rawurldecode($request->getPathInfo())) { + if ($this->fragmentPath !== rawurldecode($request->getPathInfo())) { + return; + } + + if ($request->attributes->has('_controller')) { + // Is a sub-request: no need to parse _path but it should still be removed from query parameters as below. + $request->query->remove('_path'); + return; } diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php index fd5d63b167..7cfce98f2e 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php @@ -89,6 +89,31 @@ class FragmentListenerTest extends \PHPUnit_Framework_TestCase $this->assertFalse($request->query->has('_path')); } + public function testRemovesPathWithControllerDefined() + { + $request = Request::create('http://example.com/_fragment?_path=foo%3Dbar%26_controller%3Dfoo'); + + $listener = new FragmentListener(new UriSigner('foo')); + $event = $this->createGetResponseEvent($request, HttpKernelInterface::SUB_REQUEST); + + $listener->onKernelRequest($event); + + $this->assertFalse($request->query->has('_path')); + } + + public function testRemovesPathWithControllerNotDefined() + { + $signer = new UriSigner('foo'); + $request = Request::create($signer->sign('http://example.com/_fragment?_path=foo%3Dbar'), 'GET', array(), array(), array(), array('REMOTE_ADDR' => '10.0.0.1')); + + $listener = new FragmentListener($signer); + $event = $this->createGetResponseEvent($request); + + $listener->onKernelRequest($event); + + $this->assertFalse($request->query->has('_path')); + } + private function createGetResponseEvent(Request $request, $requestType = HttpKernelInterface::MASTER_REQUEST) { return new GetResponseEvent($this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), $request, $requestType); From 97c5d27c598c678de8d56770e58fafdd05688fd3 Mon Sep 17 00:00:00 2001 From: Ener-Getick Date: Wed, 2 Mar 2016 13:48:01 +0100 Subject: [PATCH 09/12] Allow to normalize \Traversable --- .../Component/Serializer/Encoder/XmlEncoder.php | 2 +- .../Serializer/Tests/Encoder/XmlEncoderTest.php | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php index d3fe2588ac..6a2b5cf452 100644 --- a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php @@ -305,7 +305,7 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec { $append = true; - if (is_array($data) || $data instanceof \Traversable) { + if (is_array($data) || ($data instanceof \Traversable && !$this->serializer->supportsNormalization($data, $this->format))) { foreach ($data as $key => $data) { //Ah this is the magic @ attribute types. if (0 === strpos($key, '@') && is_scalar($data) && $this->isElementNameValid($attributeName = substr($key, 1))) { diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php index bb3e7fb564..c4697b202a 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Serializer\Tests\Encoder; use Symfony\Component\Serializer\Tests\Fixtures\Dummy; +use Symfony\Component\Serializer\Tests\Fixtures\NormalizableTraversableDummy; use Symfony\Component\Serializer\Tests\Fixtures\ScalarDummy; use Symfony\Component\Serializer\Encoder\XmlEncoder; use Symfony\Component\Serializer\Serializer; @@ -203,6 +204,21 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expected, $serializer->serialize($array, 'xml', $options)); } + public function testEncodeTraversableWhenNormalizable() { + $this->encoder = new XmlEncoder(); + $serializer = new Serializer(array(new CustomNormalizer()), array('xml' => new XmlEncoder())); + $this->encoder->setSerializer($serializer); + + $expected = << +normalizedFoonormalizedBar + +XML; + + $this->assertEquals($expected, $serializer->serialize(new NormalizableTraversableDummy(), 'xml')); + + } + public function testDecode() { $source = $this->getXmlSource(); From d8c493f0761bc472309b7ac24468962e8a4ffc73 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Mon, 22 Feb 2016 18:48:09 +0000 Subject: [PATCH 10/12] [FrameworkBundle] Fix a regression in handling absolute and namespaced template paths --- .../FrameworkBundle/Templating/TemplateNameParser.php | 7 ++++++- .../Tests/Templating/TemplateNameParserTest.php | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php index 6faafc005e..96e18eda88 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php @@ -56,7 +56,7 @@ class TemplateNameParser extends BaseTemplateNameParser throw new \RuntimeException(sprintf('Template name "%s" contains invalid characters.', $name)); } - if (!preg_match('/^(?:([^:]*):)?(?:([^:]*):)?(.+)\.([^\.]+)\.([^\.]+)$/', $name, $matches)) { + if (!preg_match('/^(?:([^:]*):([^:]*):)?(.+)\.([^\.]+)\.([^\.]+)$/', $name, $matches) || $this->isAbsolutePath($name) || 0 === strpos($name, '@')) { return parent::parse($name); } @@ -72,4 +72,9 @@ class TemplateNameParser extends BaseTemplateNameParser return $this->cache[$name] = $template; } + + private function isAbsolutePath($file) + { + return (bool) preg_match('#^(?:/|[a-zA-Z]:)#', $file); + } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php index 4ff824bf7c..479475732c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php @@ -66,6 +66,12 @@ class TemplateNameParserTest extends TestCase array('::index.html.php', '::index.html.php', 'views/index.html.php', new TemplateReference('', '', 'index', 'html', 'php')), array('index.html.php', '::index.html.php', 'views/index.html.php', new TemplateReference('', '', 'index', 'html', 'php')), array('FooBundle:Post:foo.bar.index.html.php', 'FooBundle:Post:foo.bar.index.html.php', '@FooBundle/Resources/views/Post/foo.bar.index.html.php', new TemplateReference('FooBundle', 'Post', 'foo.bar.index', 'html', 'php')), + array('@FooBundle/Resources/views/layout.html.twig', '@FooBundle/Resources/views/layout.html.twig', '@FooBundle/Resources/views/layout.html.twig', new BaseTemplateReference('@FooBundle/Resources/views/layout.html.twig', 'twig')), + array('@FooBundle/Foo/layout.html.twig', '@FooBundle/Foo/layout.html.twig', '@FooBundle/Foo/layout.html.twig', new BaseTemplateReference('@FooBundle/Foo/layout.html.twig', 'twig')), + array('/path/to/section/index.html.php', '/path/to/section/index.html.php', '/path/to/section/index.html.php', new BaseTemplateReference('/path/to/section/index.html.php', 'php')), + array('C:\\path\\to\\section\\name.html.php', 'C:path/to/section/name.html.php', 'C:path/to/section/name.html.php', new BaseTemplateReference('C:path/to/section/name.html.php', 'php')), + array('C:\\path\\to\\section\\name:foo.html.php', 'C:path/to/section/name:foo.html.php', 'C:path/to/section/name:foo.html.php', new BaseTemplateReference('C:path/to/section/name:foo.html.php', 'php')), + array('\\path\\to\\section\\name.html.php', '/path/to/section/name.html.php', '/path/to/section/name.html.php', new BaseTemplateReference('/path/to/section/name.html.php', 'php')), array('/path/to/section/name.php', '/path/to/section/name.php', '/path/to/section/name.php', new BaseTemplateReference('/path/to/section/name.php', 'php')), array('name.twig', 'name.twig', 'name.twig', new BaseTemplateReference('name.twig', 'twig')), array('name', 'name', 'name', new BaseTemplateReference('name')), From d5bbc3c6cb26f8fd737d96fffaff3c4cf2c09581 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 3 Mar 2016 18:24:01 +0100 Subject: [PATCH 11/12] [TwigBundle] Fix failing test on appveyor --- .../Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php index cc993c7527..8f1b24c877 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php @@ -101,7 +101,7 @@ class FilesystemLoaderTest extends TestCase /** * @expectedException \Twig_Error_Loader - * @expectedExceptionMessageRegExp /Unable to find template "name\.format\.engine" \(looked into: .*\/Tests\/Loader\/\.\.\/DependencyInjection\/Fixtures\/Resources\/views\)/ + * @expectedExceptionMessageRegExp /Unable to find template "name\.format\.engine" \(looked into: .*Tests.Loader.\.\..DependencyInjection.Fixtures.Resources.views\)/ */ public function testTwigErrorIfTemplateDoesNotExist() { From 2e812481c9c4646fd495f8217e758b52020a80ad Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 3 Mar 2016 13:05:42 +0100 Subject: [PATCH 12/12] Updated all the README files --- src/Symfony/Bridge/Doctrine/README.md | 9 +- src/Symfony/Bridge/Monolog/README.md | 9 +- src/Symfony/Bridge/Propel1/README.md | 9 +- src/Symfony/Bridge/ProxyManager/README.md | 9 +- src/Symfony/Bridge/Twig/README.md | 10 +- src/Symfony/Component/BrowserKit/README.md | 23 +--- src/Symfony/Component/ClassLoader/README.md | 85 +----------- src/Symfony/Component/Config/README.md | 18 ++- src/Symfony/Component/Console/README.md | 71 ++-------- src/Symfony/Component/CssSelector/README.md | 47 ++----- src/Symfony/Component/Debug/README.md | 43 +----- .../Component/DependencyInjection/README.md | 81 +---------- src/Symfony/Component/DomCrawler/README.md | 35 +---- .../Component/EventDispatcher/README.md | 28 ++-- src/Symfony/Component/Filesystem/README.md | 46 +------ src/Symfony/Component/Finder/README.md | 53 +------- src/Symfony/Component/Form/README.md | 25 +--- .../Component/HttpFoundation/README.md | 56 +------- src/Symfony/Component/HttpKernel/README.md | 101 ++------------ src/Symfony/Component/Intl/README.md | 22 ++- src/Symfony/Component/Locale/README.md | 2 +- .../Component/OptionsResolver/README.md | 116 ++-------------- src/Symfony/Component/Process/README.md | 50 +------ .../Component/PropertyAccess/README.md | 14 +- src/Symfony/Component/Routing/README.md | 35 +---- src/Symfony/Component/Security/README.md | 27 ++-- src/Symfony/Component/Serializer/README.md | 17 +-- src/Symfony/Component/Stopwatch/README.md | 12 +- src/Symfony/Component/Templating/README.md | 21 +-- src/Symfony/Component/Translation/README.md | 36 +---- src/Symfony/Component/Validator/README.md | 126 ++---------------- src/Symfony/Component/Yaml/README.md | 20 +-- 32 files changed, 219 insertions(+), 1037 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/README.md b/src/Symfony/Bridge/Doctrine/README.md index 3dabc3cd6d..46d897d061 100644 --- a/src/Symfony/Bridge/Doctrine/README.md +++ b/src/Symfony/Bridge/Doctrine/README.md @@ -7,8 +7,7 @@ various Symfony components. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Bridge/Doctrine/ - $ composer install - $ phpunit + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Bridge/Monolog/README.md b/src/Symfony/Bridge/Monolog/README.md index b0d91ca4f4..2d19b3e27c 100644 --- a/src/Symfony/Bridge/Monolog/README.md +++ b/src/Symfony/Bridge/Monolog/README.md @@ -6,8 +6,7 @@ Provides integration for Monolog with various Symfony components. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Bridge/Monolog/ - $ composer install - $ phpunit + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Bridge/Propel1/README.md b/src/Symfony/Bridge/Propel1/README.md index 22590ca583..41286745ab 100644 --- a/src/Symfony/Bridge/Propel1/README.md +++ b/src/Symfony/Bridge/Propel1/README.md @@ -6,8 +6,7 @@ Provides integration for Propel with various Symfony components. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Bridge/Propel1/ - $ composer install - $ phpunit + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Bridge/ProxyManager/README.md b/src/Symfony/Bridge/ProxyManager/README.md index 35d41998b8..38d3d69645 100644 --- a/src/Symfony/Bridge/ProxyManager/README.md +++ b/src/Symfony/Bridge/ProxyManager/README.md @@ -6,10 +6,9 @@ Provides integration for [ProxyManager][1] with various Symfony components. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Bridge/ProxyManager/ - $ composer install - $ phpunit + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) [1]: https://github.com/Ocramius/ProxyManager diff --git a/src/Symfony/Bridge/Twig/README.md b/src/Symfony/Bridge/Twig/README.md index 1f92af944f..eb084147c3 100644 --- a/src/Symfony/Bridge/Twig/README.md +++ b/src/Symfony/Bridge/Twig/README.md @@ -7,9 +7,7 @@ Symfony components. Resources --------- -If you want to run the unit tests, install dev dependencies before -running PHPUnit: - - $ cd path/to/Symfony/Bridge/Twig/ - $ composer install - $ phpunit + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/BrowserKit/README.md b/src/Symfony/Component/BrowserKit/README.md index 5600fe2e1f..a0083ac5bd 100644 --- a/src/Symfony/Component/BrowserKit/README.md +++ b/src/Symfony/Component/BrowserKit/README.md @@ -1,23 +1,14 @@ BrowserKit Component ==================== -BrowserKit simulates the behavior of a web browser. - -The component only provides an abstract client and does not provide any -"default" backend for the HTTP layer. +The BrowserKit component simulates the behavior of a web browser, allowing you +to make requests, click on links and submit forms programmatically. Resources --------- -For a simple implementation of a browser based on an HTTP layer, have a look -at [Goutte](https://github.com/FriendsOfPHP/Goutte). - -For an implementation based on HttpKernelInterface, have a look at the -[Client](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKernel/Client.php) -provided by the HttpKernel component. - -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/BrowserKit/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/browser_kit/introduction.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/ClassLoader/README.md b/src/Symfony/Component/ClassLoader/README.md index 0d2955dc97..d61992b6a8 100644 --- a/src/Symfony/Component/ClassLoader/README.md +++ b/src/Symfony/Component/ClassLoader/README.md @@ -1,85 +1,14 @@ ClassLoader Component ===================== -ClassLoader loads your project classes automatically if they follow some -standard PHP conventions. - -The ClassLoader object is able to autoload classes that implement the PSR-0 -standard or the PEAR naming convention. - -First, register the autoloader: - -```php -require_once __DIR__.'/src/Symfony/Component/ClassLoader/ClassLoader.php'; - -use Symfony\Component\ClassLoader\ClassLoader; - -$loader = new ClassLoader(); -$loader->register(); -``` - -Then, register some namespaces with the `addPrefix()` method: - -```php -$loader->addPrefix('Symfony', __DIR__.'/src'); -$loader->addPrefix('Monolog', __DIR__.'/vendor/monolog/src'); -``` - -The `addPrefix()` method takes a namespace prefix and a path where to -look for the classes as arguments. - -You can also register a sub-namespaces: - -```php -$loader->addPrefix('Doctrine\\Common', __DIR__.'/vendor/doctrine-common/lib'); -``` - -The order of registration is significant and the first registered namespace -takes precedence over later registered one. - -You can also register more than one path for a given namespace: - -```php -$loader->addPrefix('Symfony', array(__DIR__.'/src', __DIR__.'/symfony/src')); -``` - -Alternatively, you can use the `addPrefixes()` method to register more -than one namespace at once: - -```php -$loader->addPrefixes(array( - 'Symfony' => array(__DIR__.'/src', __DIR__.'/symfony/src'), - 'Doctrine\\Common' => __DIR__.'/vendor/doctrine-common/lib', - 'Doctrine' => __DIR__.'/vendor/doctrine/lib', - 'Monolog' => __DIR__.'/vendor/monolog/src', -)); -``` - -For better performance, you can use the APC class loader: - -```php -require_once __DIR__.'/src/Symfony/Component/ClassLoader/ClassLoader.php'; -require_once __DIR__.'/src/Symfony/Component/ClassLoader/ApcClassLoader.php'; - -use Symfony\Component\ClassLoader\ClassLoader; -use Symfony\Component\ClassLoader\ApcClassLoader; - -$loader = new ClassLoader(); -$loader->addPrefix('Symfony', __DIR__.'/src'); - -$loader = new ApcClassLoader('apc.prefix.', $loader); -$loader->register(); -``` - -Furthermore, the component provides tools to aggregate classes into a single -file, which is especially useful to improve performance on servers that do not -provide byte caches. +The ClassLoader component provides tools to autoload your classes and cache +their locations for performance. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/ClassLoader/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/class_loader/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Config/README.md b/src/Symfony/Component/Config/README.md index 690d7d74f9..bf400da196 100644 --- a/src/Symfony/Component/Config/README.md +++ b/src/Symfony/Component/Config/README.md @@ -1,17 +1,15 @@ Config Component ================ -Config provides the infrastructure for loading configurations from different -data sources and optionally monitoring these data sources for changes. There -are additional tools for validating, normalizing and handling of defaults that -can optionally be used to convert from different formats to arrays. +The Config component provides several classes to help you find, load, combine, +autofill and validate configuration values of any kind, whatever their source +may be (YAML, XML, INI files, or for instance a database). Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Config/ - $ composer install - $ phpunit - + * [Documentation](https://symfony.com/doc/current/components/config/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Console/README.md b/src/Symfony/Component/Console/README.md index 25f700c8d4..664a37c0ee 100644 --- a/src/Symfony/Component/Console/README.md +++ b/src/Symfony/Component/Console/README.md @@ -1,67 +1,20 @@ Console Component ================= -Console eases the creation of beautiful and testable command line interfaces. - -The Application object manages the CLI application: - -```php -use Symfony\Component\Console\Application; - -$console = new Application(); -$console->run(); -``` - -The ``run()`` method parses the arguments and options passed on the command -line and executes the right command. - -Registering a new command can easily be done via the ``register()`` method, -which returns a ``Command`` instance: - -```php -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Output\OutputInterface; - -$console - ->register('ls') - ->setDefinition(array( - new InputArgument('dir', InputArgument::REQUIRED, 'Directory name'), - )) - ->setDescription('Displays the files in the given directory') - ->setCode(function (InputInterface $input, OutputInterface $output) { - $dir = $input->getArgument('dir'); - - $output->writeln(sprintf('Dir listing for %s', $dir)); - }) -; -``` - -You can also register new commands via classes. - -The component provides a lot of features like output coloring, input and -output abstractions (so that you can easily unit-test your commands), -validation, automatic help messages, ... - -Tests ------ - -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Console/ - $ composer install - $ phpunit - -Third Party ------------ - -`Resources/bin/hiddeninput.exe` is a third party binary provided within this -component. Find sources and license at https://github.com/Seldaek/hidden-input. +The Console component eases the creation of beautiful and testable command line +interfaces. Resources --------- -[The Console Component](https://symfony.com/doc/current/components/console.html) + * [Documentation](https://symfony.com/doc/current/components/console/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) -[How to create a Console Command](https://symfony.com/doc/current/cookbook/console/console_command.html) +Credits +------- + +`Resources/bin/hiddeninput.exe` is a third party binary provided within this +component. Find sources and license at https://github.com/Seldaek/hidden-input. diff --git a/src/Symfony/Component/CssSelector/README.md b/src/Symfony/Component/CssSelector/README.md index ffe6c890f6..7c4c411635 100644 --- a/src/Symfony/Component/CssSelector/README.md +++ b/src/Symfony/Component/CssSelector/README.md @@ -1,47 +1,20 @@ CssSelector Component ===================== -CssSelector converts CSS selectors to XPath expressions. - -The component only goal is to convert CSS selectors to their XPath -equivalents: - -```php -use Symfony\Component\CssSelector\CssSelector; - -print CssSelector::toXPath('div.item > h4 > a'); -``` - -HTML and XML are different --------------------------- - -The `CssSelector` component comes with an `HTML` extension which is enabled by -default. If you need to use this component with `XML` documents, you have to -disable this `HTML` extension. That's because, `HTML` tag & attribute names -are always lower-cased, but case-sensitive in `XML`: - -```php -// disable `HTML` extension: -CssSelector::disableHtmlExtension(); - -// re-enable `HTML` extension: -CssSelector::enableHtmlExtension(); -``` - -When the `HTML` extension is enabled, tag names are lower-cased, attribute -names are lower-cased, the following extra pseudo-classes are supported: -`checked`, `link`, `disabled`, `enabled`, `selected`, `invalid`, `hover`, -`visited`, and the `lang()` function is also added. +The CssSelector component converts CSS selectors to XPath expressions. Resources --------- + * [Documentation](https://symfony.com/doc/current/components/css_selector.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) + +Credits +------- + This component is a port of the Python cssselect library [v0.7.1](https://github.com/SimonSapin/cssselect/releases/tag/v0.7.1), which is distributed under the BSD license. - -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/CssSelector/ - $ composer install - $ phpunit diff --git a/src/Symfony/Component/Debug/README.md b/src/Symfony/Component/Debug/README.md index ad10a41889..a1d16175c1 100644 --- a/src/Symfony/Component/Debug/README.md +++ b/src/Symfony/Component/Debug/README.md @@ -1,44 +1,13 @@ Debug Component =============== -Debug provides tools to make debugging easier. - -Enabling all debug tools is as easy as calling the `enable()` method on the -main `Debug` class: - -```php -use Symfony\Component\Debug\Debug; - -Debug::enable(); -``` - -You can also use the tools individually: - -```php -use Symfony\Component\Debug\ErrorHandler; -use Symfony\Component\Debug\ExceptionHandler; - -error_reporting(-1); - -ErrorHandler::register($errorReportingLevel); -if ('cli' !== php_sapi_name()) { - ExceptionHandler::register(); -} elseif (!ini_get('log_errors') || ini_get('error_log')) { - ini_set('display_errors', 1); -} -``` - -Note that the `Debug::enable()` call also registers the debug class loader -from the Symfony ClassLoader component when available. - -This component can optionally take advantage of the features of the HttpKernel -and HttpFoundation components. +The Debug component provides tools to ease debugging PHP code. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Debug/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/debug/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/DependencyInjection/README.md b/src/Symfony/Component/DependencyInjection/README.md index 66f62be5de..932647f94a 100644 --- a/src/Symfony/Component/DependencyInjection/README.md +++ b/src/Symfony/Component/DependencyInjection/README.md @@ -1,81 +1,14 @@ DependencyInjection Component ============================= -DependencyInjection manages your services via a robust and flexible Dependency -Injection Container. - -Here is a simple example that shows how to register services and parameters: - -```php -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Reference; - -$sc = new ContainerBuilder(); -$sc - ->register('foo', '%foo.class%') - ->addArgument(new Reference('bar')) -; -$sc->setParameter('foo.class', 'Foo'); - -$sc->get('foo'); -``` - -Method Calls (Setter Injection): - -```php -$sc = new ContainerBuilder(); - -$sc - ->register('bar', '%bar.class%') - ->addMethodCall('setFoo', array(new Reference('foo'))) -; -$sc->setParameter('bar.class', 'Bar'); - -$sc->get('bar'); -``` - -Factory Class: - -If your service is retrieved by calling a static method: - -```php -$sc = new ContainerBuilder(); - -$sc - ->register('bar', '%bar.class%') - ->setFactoryClass('%bar.class%') - ->setFactoryMethod('getInstance') - ->addArgument('Aarrg!!!') -; -$sc->setParameter('bar.class', 'Bar'); - -$sc->get('bar'); -``` - -File Include: - -For some services, especially those that are difficult or impossible to -autoload, you may need the container to include a file before -instantiating your class. - -```php -$sc = new ContainerBuilder(); - -$sc - ->register('bar', '%bar.class%') - ->setFile('/path/to/file') - ->addArgument('Aarrg!!!') -; -$sc->setParameter('bar.class', 'Bar'); - -$sc->get('bar'); -``` +The DependencyInjection component allows you to standardize and centralize the +way objects are constructed in your application. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/DependencyInjection/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/dependency_injection/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/DomCrawler/README.md b/src/Symfony/Component/DomCrawler/README.md index d2c8de5da4..5fad2e27ad 100644 --- a/src/Symfony/Component/DomCrawler/README.md +++ b/src/Symfony/Component/DomCrawler/README.md @@ -1,36 +1,13 @@ DomCrawler Component ==================== -DomCrawler eases DOM navigation for HTML and XML documents. - -If you are familiar with jQuery, DomCrawler is a PHP equivalent: - -```php -use Symfony\Component\DomCrawler\Crawler; - -$crawler = new Crawler(); -$crawler->addContent('

Hello World!

'); - -print $crawler->filterXPath('descendant-or-self::body/p')->text(); -``` - -If you are also using the CssSelector component, you can use CSS Selectors -instead of XPath expressions: - -```php -use Symfony\Component\DomCrawler\Crawler; - -$crawler = new Crawler(); -$crawler->addContent('

Hello World!

'); - -print $crawler->filter('body > p')->text(); -``` +The DomCrawler component eases DOM navigation for HTML and XML documents. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/DomCrawler/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/dom_crawler.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/EventDispatcher/README.md b/src/Symfony/Component/EventDispatcher/README.md index 8031f4dd3f..185c3fecf8 100644 --- a/src/Symfony/Component/EventDispatcher/README.md +++ b/src/Symfony/Component/EventDispatcher/README.md @@ -1,27 +1,15 @@ EventDispatcher Component ========================= -The Symfony EventDispatcher component implements the Mediator pattern in a -simple and effective way to make your projects truly extensible. - -```php -use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\EventDispatcher\Event; - -$dispatcher = new EventDispatcher(); - -$dispatcher->addListener('event_name', function (Event $event) { - // ... -}); - -$dispatcher->dispatch('event_name'); -``` +The EventDispatcher component provides tools that allow your application +components to communicate with each other by dispatching events and listening to +them. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/EventDispatcher/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/event_dispatcher/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Filesystem/README.md b/src/Symfony/Component/Filesystem/README.md index df09f93dce..877ab3543f 100644 --- a/src/Symfony/Component/Filesystem/README.md +++ b/src/Symfony/Component/Filesystem/README.md @@ -1,47 +1,13 @@ Filesystem Component ==================== -Filesystem provides basic utility to manipulate the file system: - -```php -copy($originFile, $targetFile, $override = false); - -$filesystem->mkdir($dirs, $mode = 0777); - -$filesystem->touch($files, $time = null, $atime = null); - -$filesystem->remove($files); - -$filesystem->exists($files); - -$filesystem->chmod($files, $mode, $umask = 0000, $recursive = false); - -$filesystem->chown($files, $user, $recursive = false); - -$filesystem->chgrp($files, $group, $recursive = false); - -$filesystem->rename($origin, $target); - -$filesystem->symlink($originDir, $targetDir, $copyOnWindows = false); - -$filesystem->makePathRelative($endPath, $startPath); - -$filesystem->mirror($originDir, $targetDir, \Traversable $iterator = null, $options = array()); - -$filesystem->isAbsolutePath($file); -``` +The Filesystem component provides basic utilities for the filesystem. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Filesystem/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/filesystem/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Finder/README.md b/src/Symfony/Component/Finder/README.md index 4fb1eca007..0b19c75257 100644 --- a/src/Symfony/Component/Finder/README.md +++ b/src/Symfony/Component/Finder/README.md @@ -1,53 +1,14 @@ Finder Component ================ -Finder finds files and directories via an intuitive fluent interface. - -```php -use Symfony\Component\Finder\Finder; - -$finder = new Finder(); - -$iterator = $finder - ->files() - ->name('*.php') - ->depth(0) - ->size('>= 1K') - ->in(__DIR__); - -foreach ($iterator as $file) { - print $file->getRealpath()."\n"; -} -``` - -The iterator returns instances of [Symfony\Component\Finder\SplFileInfo\SplFileInfo][1]. -Besides the build-in methods inherited from [\SplFileInfo][2] (`getPerms()`, `getSize()`, ...), -you can also use `getRelativePath()` and `getRelativePathname()`. Read the -[official documentation][3] for more information. - -But you can also use it to find files stored remotely like in this example where -we are looking for files on Amazon S3: - -```php -$s3 = new \Zend_Service_Amazon_S3($key, $secret); -$s3->registerStreamWrapper("s3"); - -$finder = new Finder(); -$finder->name('photos*')->size('< 100K')->date('since 1 hour ago'); -foreach ($finder->in('s3://bucket-name') as $file) { - print $file->getFilename()."\n"; -} -``` +The Finder component finds files and directories via an intuitive fluent +interface. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Finder/ - $ composer install - $ phpunit - -[1]: http://api.symfony.com/2.5/Symfony/Component/Finder/SplFileInfo.html -[2]: http://php.net/splfileinfo -[3]: https://symfony.com/doc/current/components/finder.html#usage + * [Documentation](https://symfony.com/doc/current/components/finder.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Form/README.md b/src/Symfony/Component/Form/README.md index a2f24777af..3fe6f8bbf3 100644 --- a/src/Symfony/Component/Form/README.md +++ b/src/Symfony/Component/Form/README.md @@ -1,26 +1,13 @@ Form Component ============== -Form provides tools for defining forms, rendering and mapping request data to -related models. Furthermore it provides integration with the Validation -component. +The Form component allows you to easily create, process and reuse HTML forms. Resources --------- -Silex integration: - -https://github.com/silexphp/Silex/blob/master/src/Silex/Provider/FormServiceProvider.php - -Documentation: - -https://symfony.com/doc/2.3/book/forms.html - -Resources ---------- - -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Form/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/form/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/HttpFoundation/README.md b/src/Symfony/Component/HttpFoundation/README.md index 11ad6eef54..8907f0b967 100644 --- a/src/Symfony/Component/HttpFoundation/README.md +++ b/src/Symfony/Component/HttpFoundation/README.md @@ -1,56 +1,14 @@ HttpFoundation Component ======================== -HttpFoundation defines an object-oriented layer for the HTTP specification. - -It provides an abstraction for requests, responses, uploaded files, cookies, -sessions, ... - -In this example, we get a Request object from the current PHP global -variables: - -```php -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -$request = Request::createFromGlobals(); -echo $request->getPathInfo(); -``` - -You can also create a Request directly -- that's interesting for unit testing: - -```php -$request = Request::create('/?foo=bar', 'GET'); -echo $request->getPathInfo(); -``` - -And here is how to create and send a Response: - -```php -$response = new Response('Not Found', 404, array('Content-Type' => 'text/plain')); -$response->send(); -``` - -The Request and the Response classes have many other methods that implement -the HTTP specification. - -Loading -------- - -If you are not using Composer but are using PHP 5.3.x, you must add the following to your autoloader: - -```php -// SessionHandlerInterface -if (!interface_exists('SessionHandlerInterface')) { - $loader->registerPrefixFallback(__DIR__.'/../vendor/symfony/src/Symfony/Component/HttpFoundation/Resources/stubs'); -} -``` +The HttpFoundation component defines an object-oriented layer for the HTTP +specification. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/HttpFoundation/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/http_foundation/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/HttpKernel/README.md b/src/Symfony/Component/HttpKernel/README.md index 9ec8c0427b..cc5e74b6bc 100644 --- a/src/Symfony/Component/HttpKernel/README.md +++ b/src/Symfony/Component/HttpKernel/README.md @@ -1,99 +1,16 @@ HttpKernel Component ==================== -HttpKernel provides the building blocks to create flexible and fast HTTP-based -frameworks. - -``HttpKernelInterface`` is the core interface of the Symfony full-stack -framework: - -```php -interface HttpKernelInterface -{ - /** - * Handles a Request to convert it to a Response. - * - * @param Request $request A Request instance - * - * @return Response A Response instance - */ - function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true); -} -``` - -It takes a ``Request`` as an input and should return a ``Response`` as an -output. Using this interface makes your code compatible with all frameworks -using the Symfony components. And this will give you many cool features for -free. - -Creating a framework based on the Symfony components is really easy. Here is -a very simple, but fully-featured framework based on the Symfony components: - -```php -$routes = new RouteCollection(); -$routes->add('hello', new Route('/hello', array('_controller' => - function (Request $request) { - return new Response(sprintf("Hello %s", $request->get('name'))); - } -))); - -$request = Request::createFromGlobals(); - -$context = new RequestContext(); -$context->fromRequest($request); - -$matcher = new UrlMatcher($routes, $context); - -$dispatcher = new EventDispatcher(); -$dispatcher->addSubscriber(new RouterListener($matcher)); - -$resolver = new ControllerResolver(); - -$kernel = new HttpKernel($dispatcher, $resolver); - -$kernel->handle($request)->send(); -``` - -This is all you need to create a flexible framework with the Symfony -components. - -Want to add an HTTP reverse proxy and benefit from HTTP caching and Edge Side -Includes? - -```php -$kernel = new HttpKernel($dispatcher, $resolver); - -$kernel = new HttpCache($kernel, new Store(__DIR__.'/cache')); -``` - -Want to functional test this small framework? - -```php -$client = new Client($kernel); -$crawler = $client->request('GET', '/hello/Fabien'); - -$this->assertEquals('Fabien', $crawler->filter('p > span')->text()); -``` - -Want nice error pages instead of ugly PHP exceptions? - -```php -$dispatcher->addSubscriber(new ExceptionListener(function (Request $request) { - $msg = 'Something went wrong! ('.$request->get('exception')->getMessage().')'; - - return new Response($msg, 500); -})); -``` - -And that's why the simple looking ``HttpKernelInterface`` is so powerful. It -gives you access to a lot of cool features, ready to be used out of the box, -with no efforts. +The HttpKernel component provides a structured process for converting a Request +into a Response by making use of the EventDispatcher component. It's flexible +enough to create a full-stack framework (Symfony), a micro-framework (Silex) or +an advanced CMS system (Drupal). Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/HttpKernel/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/http_kernel/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Intl/README.md b/src/Symfony/Component/Intl/README.md index 43f86a31b8..30cb5093c4 100644 --- a/src/Symfony/Component/Intl/README.md +++ b/src/Symfony/Component/Intl/README.md @@ -1,25 +1,19 @@ Intl Component ============= -A PHP replacement layer for the C intl extension that includes additional data -from the ICU library. +A PHP replacement layer for the C intl extension that also provides access to +the localization data of the ICU library. The replacement layer is limited to the locale "en". If you want to use other -locales, you should [install the intl extension] [0] instead. - -Documentation -------------- - -The documentation for the component can be found [online] [1]. +locales, you should [install the intl PHP extension] [0] instead. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Intl/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/intl.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) [0]: http://www.php.net/manual/en/intl.setup.php -[1]: https://symfony.com/doc/2.3/components/intl.html diff --git a/src/Symfony/Component/Locale/README.md b/src/Symfony/Component/Locale/README.md index d2298ec532..cea6d8af58 100644 --- a/src/Symfony/Component/Locale/README.md +++ b/src/Symfony/Component/Locale/README.md @@ -4,5 +4,5 @@ Locale Component Locale provides fallback code to handle cases when the ``intl`` extension is missing. -The Locale component is deprecated since version 2.3 and will be removed in +The Locale component is deprecated since version 2.3 and was removed in Symfony 3.0. You should use the more capable Intl component instead. diff --git a/src/Symfony/Component/OptionsResolver/README.md b/src/Symfony/Component/OptionsResolver/README.md index bb54c287c1..5768f68e7f 100644 --- a/src/Symfony/Component/OptionsResolver/README.md +++ b/src/Symfony/Component/OptionsResolver/README.md @@ -1,115 +1,15 @@ OptionsResolver Component ========================= -OptionsResolver helps at configuring objects with option arrays. - -It supports default values on different levels of your class hierarchy, -option constraints (required vs. optional, allowed values) and lazy options -whose default value depends on the value of another option. - -The following example demonstrates a Person class with two required options -"firstName" and "lastName" and two optional options "age" and "gender", where -the default value of "gender" is derived from the passed first name, if -possible, and may only be one of "male" and "female". - -```php -use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; -use Symfony\Component\OptionsResolver\Options; - -class Person -{ - protected $options; - - public function __construct(array $options = array()) - { - $resolver = new OptionsResolver(); - $this->setDefaultOptions($resolver); - - $this->options = $resolver->resolve($options); - } - - protected function setDefaultOptions(OptionsResolverInterface $resolver) - { - $resolver->setRequired(array( - 'firstName', - 'lastName', - )); - - $resolver->setDefaults(array( - 'age' => null, - 'gender' => function (Options $options) { - if (self::isKnownMaleName($options['firstName'])) { - return 'male'; - } - - return 'female'; - }, - )); - - $resolver->setAllowedValues(array( - 'gender' => array('male', 'female'), - )); - } -} -``` - -We can now easily instantiate a Person object: - -```php -// 'gender' is implicitly set to 'female' -$person = new Person(array( - 'firstName' => 'Jane', - 'lastName' => 'Doe', -)); -``` - -We can also override the default values of the optional options: - -```php -$person = new Person(array( - 'firstName' => 'Abdullah', - 'lastName' => 'Mogashi', - 'gender' => 'male', - 'age' => 30, -)); -``` - -Options can be added or changed in subclasses by overriding the `setDefaultOptions` -method: - -```php -use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\OptionsResolver\Options; - -class Employee extends Person -{ - protected function setDefaultOptions(OptionsResolverInterface $resolver) - { - parent::setDefaultOptions($resolver); - - $resolver->setRequired(array( - 'birthDate', - )); - - $resolver->setDefaults(array( - // $previousValue contains the default value configured in the - // parent class - 'age' => function (Options $options, $previousValue) { - return self::calculateAge($options['birthDate']); - } - )); - } -} -``` - - +The OptionsResolver component is `array_replace on steroids. It allows you to +create an options system with required options, defaults, validation (type, +value), normalization and more. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/OptionsResolver/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/options_resolver.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Process/README.md b/src/Symfony/Component/Process/README.md index 7c83ed413e..b7ca5b4254 100644 --- a/src/Symfony/Component/Process/README.md +++ b/src/Symfony/Component/Process/README.md @@ -1,51 +1,13 @@ Process Component ================= -Process executes commands in sub-processes. - -In this example, we run a simple directory listing and get the result back: - -```php -use Symfony\Component\Process\Process; - -$process = new Process('ls -lsa'); -$process->setTimeout(3600); -$process->run(); -if (!$process->isSuccessful()) { - throw new RuntimeException($process->getErrorOutput()); -} - -print $process->getOutput(); -``` - -You can think that this is easy to achieve with plain PHP but it's not especially -if you want to take care of the subtle differences between the different platforms. - -And if you want to be able to get some feedback in real-time, just pass an -anonymous function to the ``run()`` method and you will get the output buffer -as it becomes available: - -```php -use Symfony\Component\Process\Process; - -$process = new Process('ls -lsa'); -$process->run(function ($type, $buffer) { - if (Process::ERR === $type) { - echo 'ERR > '.$buffer; - } else { - echo 'OUT > '.$buffer; - } -}); -``` - -That's great if you want to execute a long running command (like rsync-ing files to a -remote server) and give feedback to the user in real-time. +The Process component executes commands in sub-processes. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Process/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/process.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/PropertyAccess/README.md b/src/Symfony/Component/PropertyAccess/README.md index 9fb92f058d..1959fd9e93 100644 --- a/src/Symfony/Component/PropertyAccess/README.md +++ b/src/Symfony/Component/PropertyAccess/README.md @@ -1,14 +1,14 @@ PropertyAccess Component ======================== -PropertyAccess reads/writes values from/to object/array graphs using a simple -string notation. +The PropertyAccess component provides function to read and write from/to an +object or array using a simple string notation. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/PropertyAccess/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/property_access/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Routing/README.md b/src/Symfony/Component/Routing/README.md index 1a94583a87..88fb1fde5a 100644 --- a/src/Symfony/Component/Routing/README.md +++ b/src/Symfony/Component/Routing/README.md @@ -1,36 +1,13 @@ Routing Component ================= -Routing associates a request with the code that will convert it to a response. - -The example below demonstrates how you can set up a fully working routing -system: - -```php -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\Matcher\UrlMatcher; -use Symfony\Component\Routing\RequestContext; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\Route; - -$routes = new RouteCollection(); -$routes->add('hello', new Route('/hello', array('controller' => 'foo'))); - -$context = new RequestContext(); - -// this is optional and can be done without a Request instance -$context->fromRequest(Request::createFromGlobals()); - -$matcher = new UrlMatcher($routes, $context); - -$parameters = $matcher->match('/hello'); -``` +The Routing component maps an HTTP request to a set of configuration variables. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Routing/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/routing/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Security/README.md b/src/Symfony/Component/Security/README.md index e38bc33374..b8bba12f20 100644 --- a/src/Symfony/Component/Security/README.md +++ b/src/Symfony/Component/Security/README.md @@ -1,23 +1,18 @@ Security Component ================== -Security provides an infrastructure for sophisticated authorization systems, -which makes it possible to easily separate the actual authorization logic from -so called user providers that hold the users credentials. It is inspired by -the Java Spring framework. +The Security component provides a complete security system for your web +application. It ships with facilities for authenticating using HTTP basic or +digest authentication, interactive form login or X.509 certificate login, but +also allows you to implement your own authentication strategies. Furthermore, +the component provides ways to authorize authenticated users based on their +roles, and it contains an advanced ACL system. Resources --------- -Documentation: - -https://symfony.com/doc/2.3/book/security.html - -Resources ---------- - -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Security/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/security/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Serializer/README.md b/src/Symfony/Component/Serializer/README.md index 156a288426..14270b5363 100644 --- a/src/Symfony/Component/Serializer/README.md +++ b/src/Symfony/Component/Serializer/README.md @@ -1,15 +1,16 @@ Serializer Component ==================== -With the Serializer component it's possible to handle serializing data structures, -including object graphs, into array structures or other formats like XML and JSON. -It can also handle deserializing XML and JSON back to object graphs. +With the Serializer component it's possible to handle serializing data +structures, including object graphs, into array structures or other formats like +XML and JSON. It can also handle deserializing XML and JSON back to object +graphs. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Serializer/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/serializer.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Stopwatch/README.md b/src/Symfony/Component/Stopwatch/README.md index 611df90ca5..eb0ebb3fa8 100644 --- a/src/Symfony/Component/Stopwatch/README.md +++ b/src/Symfony/Component/Stopwatch/README.md @@ -1,13 +1,13 @@ Stopwatch Component =================== -Stopwatch provides a way to profile code. +The Stopwatch component provides a way to profile code. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Stopwatch/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/stopwatch.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Templating/README.md b/src/Symfony/Component/Templating/README.md index 253eb4f507..58e2a0a5c6 100644 --- a/src/Symfony/Component/Templating/README.md +++ b/src/Symfony/Component/Templating/README.md @@ -1,18 +1,19 @@ Templating Component ==================== -Templating provides all the tools needed to build any kind of template system. +The Templating component provides all the tools needed to build any kind of +template system. -It provides an infrastructure to load template files and optionally monitor -them for changes. It also provides a concrete template engine implementation -using PHP with additional tools for escaping and separating templates into -blocks and layouts. +It provides an infrastructure to load template files and optionally monitor them +for changes. It also provides a concrete template engine implementation using +PHP with additional tools for escaping and separating templates into blocks and +layouts. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Templating/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/templating/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Translation/README.md b/src/Symfony/Component/Translation/README.md index 9a9dd80a54..46f3d1f2f2 100644 --- a/src/Symfony/Component/Translation/README.md +++ b/src/Symfony/Component/Translation/README.md @@ -1,37 +1,13 @@ Translation Component ===================== -Translation provides tools for loading translation files and generating -translated strings from these including support for pluralization. - -```php -use Symfony\Component\Translation\Translator; -use Symfony\Component\Translation\MessageSelector; -use Symfony\Component\Translation\Loader\ArrayLoader; - -$translator = new Translator('fr_FR', new MessageSelector()); -$translator->setFallbackLocales(array('fr')); -$translator->addLoader('array', new ArrayLoader()); -$translator->addResource('array', array( - 'Hello World!' => 'Bonjour', -), 'fr'); - -echo $translator->trans('Hello World!')."\n"; -``` +The Translation component provides tools to internationalize your application. Resources --------- -Silex integration: - -https://github.com/silexphp/Silex/blob/master/src/Silex/Provider/TranslationServiceProvider.php - -Documentation: - -https://symfony.com/doc/2.3/book/translation.html - -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Translation/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/translation/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Validator/README.md b/src/Symfony/Component/Validator/README.md index a1e59c7939..9dfbffb3f5 100644 --- a/src/Symfony/Component/Validator/README.md +++ b/src/Symfony/Component/Validator/README.md @@ -1,126 +1,16 @@ Validator Component =================== -This component is based on the JSR-303 Bean Validation specification and -enables specifying validation rules for classes using XML, YAML, PHP or -annotations, which can then be checked against instances of these classes. - -Usage ------ - -The component provides "validation constraints", which are simple objects -containing the rules for the validation. Let's validate a simple string -as an example: - -```php -use Symfony\Component\Validator\Validation; -use Symfony\Component\Validator\Constraints\Length; - -$validator = Validation::createValidator(); - -$violations = $validator->validateValue('Bernhard', new Length(array('min' => 10))); -``` - -This validation will fail because the given string is shorter than ten -characters. The precise errors, here called "constraint violations", are -returned by the validator. You can analyze these or return them to the user. -If the violation list is empty, validation succeeded. - -Validation of arrays is possible using the `Collection` constraint: - -```php -use Symfony\Component\Validator\Validation; -use Symfony\Component\Validator\Constraints as Assert; - -$validator = Validation::createValidator(); - -$constraint = new Assert\Collection(array( - 'name' => new Assert\Collection(array( - 'first_name' => new Assert\Length(array('min' => 101)), - 'last_name' => new Assert\Length(array('min' => 1)), - )), - 'email' => new Assert\Email(), - 'simple' => new Assert\Length(array('min' => 102)), - 'gender' => new Assert\Choice(array(3, 4)), - 'file' => new Assert\File(), - 'password' => new Assert\Length(array('min' => 60)), -)); - -$violations = $validator->validateValue($input, $constraint); -``` - -Again, the validator returns the list of violations. - -Validation of objects is possible using "constraint mapping". With such -a mapping you can put constraints onto properties and objects of classes. -Whenever an object of this class is validated, its properties and -method results are matched against the constraints. - -```php -use Symfony\Component\Validator\Validation; -use Symfony\Component\Validator\Constraints as Assert; - -class User -{ - /** - * @Assert\Length(min = 3) - * @Assert\NotBlank - */ - private $name; - - /** - * @Assert\Email - * @Assert\NotBlank - */ - private $email; - - public function __construct($name, $email) - { - $this->name = $name; - $this->email = $email; - } - - /** - * @Assert\True(message = "The user should have a Google Mail account") - */ - public function isGmailUser() - { - return false !== strpos($this->email, '@gmail.com'); - } -} - -$validator = Validation::createValidatorBuilder() - ->enableAnnotationMapping() - ->getValidator(); - -$user = new User('John Doe', 'john@example.com'); - -$violations = $validator->validate($user); -``` - -This example uses the annotation support of Doctrine Common to -map constraints to properties and methods. You can also map constraints -using XML, YAML or plain PHP, if you dislike annotations or don't want -to include Doctrine. Check the documentation for more information about -these drivers. +The Validator component provides tools to validate values following the +[JSR-303 Bean Validation specification][1]. Resources --------- -Silex integration: + * [Documentation](https://symfony.com/doc/current/book/validation.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) -https://github.com/silexphp/Silex/blob/master/src/Silex/Provider/ValidatorServiceProvider.php - -Documentation: - -https://symfony.com/doc/2.3/book/validation.html - -JSR-303 Specification: - -http://jcp.org/en/jsr/detail?id=303 - -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Validator/ - $ composer install - $ phpunit +[1]: http://jcp.org/en/jsr/detail?id=303 diff --git a/src/Symfony/Component/Yaml/README.md b/src/Symfony/Component/Yaml/README.md index 85a9786735..0d324881ce 100644 --- a/src/Symfony/Component/Yaml/README.md +++ b/src/Symfony/Component/Yaml/README.md @@ -1,21 +1,13 @@ Yaml Component ============== -YAML implements most of the YAML 1.2 specification. - -```php -use Symfony\Component\Yaml\Yaml; - -$array = Yaml::parse(file_get_contents(filename)); - -print Yaml::dump($array); -``` +The Yaml component loads and dumps YAML files. Resources --------- -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Yaml/ - $ composer install - $ phpunit + * [Documentation](https://symfony.com/doc/current/components/yaml/index.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony)