Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
BrowserKit Component | ||
==================== | ||
|
||
This component provides classes to simulate a browser for testing. | ||
BrowserKit simulates the behavior of a web browser. | ||
|
||
The component only provide an abstract client and does not provide any | ||
This comment has been minimized.
Sorry, something went wrong. |
||
"default" backend for the HTTP layer. | ||
|
||
Resources | ||
--------- | ||
|
||
Unit tests: | ||
For a simple implementation of a browser based on an HTTP layer, have a look | ||
at [Goutte](https://github.com/fabpot/Goutte). | ||
|
||
https://github.com/symfony/symfony/tree/master/tests/Symfony/Tests/Component/BrowserKit | ||
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. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,60 @@ | ||
ClassLoader Component | ||
===================== | ||
|
||
The ClassLoader component provides an autoloader that implements the PSR-0 standard | ||
(which is a standard way to autoload namespaced classes as available in PHP 5.3). | ||
It is also able to load classes that use the PEAR naming convention. It is really | ||
flexible as it can look for classes in different directories based on a sub-namespace. | ||
You can even give more than one directory for one namespace: | ||
|
||
``` | ||
require_once __DIR__.'/src/Symfony/Component/ClassLoader/UniversalClassLoader.php'; | ||
use Symfony\Component\ClassLoader\UniversalClassLoader; | ||
$loader = new UniversalClassLoader(); | ||
$loader->registerNamespaces(array( | ||
'Symfony' => array(__DIR__.'/src', __DIR__.'/symfony/src'), | ||
'Doctrine\\Common' => __DIR__.'/vendor/doctrine-common/lib', | ||
'Doctrine\\DBAL' => __DIR__.'/vendor/doctrine-dbal/lib', | ||
'Doctrine' => __DIR__.'/vendor/doctrine/lib', | ||
'Monolog' => __DIR__.'/vendor/monolog/src', | ||
)); | ||
$loader->registerPrefixes(array( | ||
'Twig_' => __DIR__.'/vendor/twig/lib', | ||
)); | ||
$loader->register(); | ||
``` | ||
|
||
Most of the time, the Symfony2 ClassLoader is all you need to autoload all your project classes. | ||
And for better performance, you can use an APC cached version of the universal class loader or | ||
the map class loader. | ||
|
||
Furthermore it provides tools to aggregate classes into a single file, which is especially | ||
useful to improve performance on servers that do not provide byte caches. | ||
|
||
Resources | ||
--------- | ||
|
||
Unit tests: | ||
|
||
https://github.com/symfony/symfony/tree/master/tests/Symfony/Tests/Component/ClassLoader | ||
ClassLoader loads your project classes automatically if they follow some | ||
standard PHP conventions. | ||
|
||
The Universal ClassLoader is able to autoload classes that implement the PSR-0 | ||
standard or the PEAR naming convention. | ||
This comment has been minimized.
Sorry, something went wrong.
stof
Member
|
||
|
||
First, register the autoloader: | ||
|
||
require_once __DIR__.'/src/Symfony/Component/ClassLoader/UniversalClassLoader.php'; | ||
|
||
use Symfony\Component\ClassLoader\UniversalClassLoader; | ||
|
||
$loader = new UniversalClassLoader(); | ||
$loader->register(); | ||
|
||
Then, register some namespaces with the `registerNamespace()` method: | ||
|
||
$loader->registerNamespace('Symfony', __DIR__.'/src'); | ||
$loader->registerNamespace('Monolog', __DIR__.'/vendor/monolog/src'); | ||
|
||
The `registerNamespace()` method takes a namespace prefix and a path where to | ||
look for the classes as arguments. | ||
|
||
You can also register a sub-namespaces: | ||
|
||
$loader->registerNamespace('Doctrine\\Common', __DIR__.'/vendor/doctrine-common/lib'); | ||
|
||
The order of registration is significant and the first registered namespace | ||
takes precedence over later registered one. | ||
This comment has been minimized.
Sorry, something went wrong.
stof
Member
|
||
|
||
You can also register more than one path for a given namespace: | ||
|
||
$loader->registerNamespace('Symfony', array(__DIR__.'/src', __DIR__.'/symfony/src')); | ||
|
||
Alternatively, you can use the `registerNamespaces()` method to register more | ||
than one namespace at once: | ||
|
||
$loader->registerNamespaces(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 based version of the universal | ||
class loader: | ||
|
||
require_once __DIR__.'/src/Symfony/Component/ClassLoader/UniversalClassLoader.php'; | ||
require_once __DIR__.'/src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php'; | ||
|
||
use Symfony\Component\ClassLoader\ApcUniversalClassLoader; | ||
|
||
$loader = new ApcUniversalClassLoader('apc.prefix.'); | ||
|
||
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. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,23 @@ | ||
CssSelector Component | ||
===================== | ||
|
||
This component is a port of the Python lxml library, which is copyright Infrae | ||
and distributed under the BSD license. | ||
|
||
Current code is a port of http://codespeak.net/svn/lxml/trunk/src/lxml/cssselect.py@71545 | ||
|
||
Using CSS selectors is far easier than using XPath. | ||
|
||
Its only goal is to convert a CSS selector to its XPath equivalent: | ||
|
||
``` | ||
use Symfony\Component\CssSelector\CssSelector; | ||
print CssSelector::toXPath('div.item > h4 > a'); | ||
``` | ||
CssSelector converts CSS selectors to XPath expressions. | ||
|
||
That way, you can just use CSS Selectors with the DomCrawler instead of XPath: | ||
The component only goal is to convert CSS selectors to their XPath | ||
equivalents: | ||
|
||
``` | ||
use Symfony\Component\DomCrawler\Crawler; | ||
use Symfony\Component\CssSelector\CssSelector; | ||
|
||
$crawler = new Crawler(); | ||
$crawler->addContent('<html><body><p>Hello World!</p></body></html>'); | ||
print $crawler->filter('body > p')->text(); | ||
``` | ||
|
||
By the way, that's one example of a component (DomCrawler) that relies | ||
on another one (CssSelector) for some optional features. | ||
print CssSelector::toXPath('div.item > h4 > a'); | ||
|
||
Resources | ||
--------- | ||
|
||
Unit tests: | ||
|
||
https://github.com/symfony/symfony/tree/master/tests/Symfony/Tests/Component/CssSelector | ||
|
||
This component is a port of the Python lxml library, which is copyright Infrae | ||
and distributed under the BSD license. | ||
|
||
Current code is a port of http://codespeak.net/svn/lxml/trunk/src/lxml/cssselect.py@71545 |
typo: provides