Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
82e73deb
Commit
82e73deb
authored
Aug 09, 2011
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed doc markup so that it is more consistent
parent
934bf3ea
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
31 additions
and
76 deletions
+31
-76
doc/extensions.rst
doc/extensions.rst
+3
-7
doc/extensions/doctrine.rst
doc/extensions/doctrine.rst
+1
-3
doc/extensions/monolog.rst
doc/extensions/monolog.rst
+1
-3
doc/extensions/translation.rst
doc/extensions/translation.rst
+3
-9
doc/extensions/twig.rst
doc/extensions/twig.rst
+2
-6
doc/extensions/url_generator.rst
doc/extensions/url_generator.rst
+1
-3
doc/extensions/validator.rst
doc/extensions/validator.rst
+4
-9
doc/services.rst
doc/services.rst
+8
-12
doc/testing.rst
doc/testing.rst
+2
-6
doc/usage.rst
doc/usage.rst
+6
-18
No files found.
doc/extensions.rst
View file @
82e73deb
...
...
@@ -8,16 +8,14 @@ Loading extensions
------------------
In order to load and use an extension, you must register it
on the application
.
::
on the application::
$app = new Silex\Application();
$app->register(new Acme\DatabaseExtension());
You can also provide some parameters as a second argument. These
will be set **before** the extension is registered.
::
will be set **before** the extension is registered::
$app->register(new Acme\DatabaseExtension(), array(
'database.dsn' => 'mysql:host=localhost;dbname=myapp',
...
...
@@ -70,9 +68,7 @@ All of these are within the ``Silex\Extension`` namespace.
Creating an extension
---------------------
Extensions must implement the ``Silex\ExtensionInterface``.
::
Extensions must implement the ``Silex\ExtensionInterface``::
interface ExtensionInterface
{
...
...
doc/extensions/doctrine.rst
View file @
82e73deb
...
...
@@ -56,9 +56,7 @@ Registering
-----------
Make sure you place a copy of *Doctrine DBAL* in ``vendor/doctrine-dbal``
and *Doctrine Common* in ``vendor/doctrine-common``.
::
and *Doctrine Common* in ``vendor/doctrine-common``::
$app->register(new Silex\Extension\DoctrineExtension(), array(
'db.options' => array(
...
...
doc/extensions/monolog.rst
View file @
82e73deb
...
...
@@ -44,9 +44,7 @@ Registering
-----------
Make sure you place a copy of *Monolog* in the ``vendor/monolog``
directory.
::
directory::
$app->register(new Silex\Extension\MonologExtension(), array(
'monolog.logfile' => __DIR__.'/development.log',
...
...
doc/extensions/translation.rst
View file @
82e73deb
...
...
@@ -38,9 +38,7 @@ Registering
-----------
Make sure you place a copy of the Symfony2 Translation component in
``vendor/symfony/src``. You can simply clone the whole Symfony2 into vendor.
::
``vendor/symfony/src``. You can simply clone the whole Symfony2 into vendor::
$app->register(new Silex\Extension\TranslationExtension(), array(
'locale_fallback' => 'en',
...
...
@@ -51,9 +49,7 @@ Usage
-----
The Translation extension provides a ``translator`` service and makes use of
the ``translator.messages`` parameter.
::
the ``translator.messages`` parameter::
$app['translator.messages'] = array(
'en' => array(
...
...
@@ -101,9 +97,7 @@ show you how to load translations from external YAML files.
First you will need the ``Config`` and ``Yaml`` components from Symfony2. Also
make sure you register them with the autoloader. You can just clone the entire
Symfony2 repository into ``vendor/symfony``.
::
Symfony2 repository into ``vendor/symfony``::
$app['autoloader']->registerNamespace('Symfony', __DIR__.'/vendor/symfony/src');
...
...
doc/extensions/twig.rst
View file @
82e73deb
...
...
@@ -39,9 +39,7 @@ Registering
-----------
Make sure you place a copy of *Twig* in the ``vendor/twig``
directory.
::
directory::
$app->register(new Silex\Extension\TwigExtension(), array(
'twig.path' => __DIR__.'/views',
...
...
@@ -56,9 +54,7 @@ directory.
Usage
-----
The Twig extension provides a ``twig`` service.
::
The Twig extension provides a ``twig`` service::
$app->get('/hello/{name}', function ($name) use ($app) {
return $app['twig']->render('hello.twig', array(
...
...
doc/extensions/url_generator.rst
View file @
82e73deb
...
...
@@ -30,9 +30,7 @@ Registering
Usage
-----
The UrlGenerator extension provides a ``url_generator`` service.
::
The UrlGenerator extension provides a ``url_generator`` service::
$app->get('/', function () {
return 'welcome to the homepage';
...
...
doc/extensions/validator.rst
View file @
82e73deb
...
...
@@ -33,9 +33,7 @@ Registering
-----------
Make sure you place a copy of the Symfony2 Validator component in
``vendor/symfony/src``. You can simply clone the whole Symfony2 into vendor.
::
``vendor/symfony/src``. You can simply clone the whole Symfony2 into vendor::
$app->register(new Silex\Extension\ValidatorExtension(), array(
'validator.class_path' => __DIR__.'/vendor/symfony/src',
...
...
@@ -49,9 +47,8 @@ The Validator extension provides a ``validator`` service.
Validating values
~~~~~~~~~~~~~~~~~
You can validate values directly using the ``validateValue`` validator method.
::
You can validate values directly using the ``validateValue`` validator
method::
use Symfony\Component\Validator\Constraints;
...
...
@@ -68,9 +65,7 @@ Validating object properties
If you want to add validations to a class, you can implement a static
``loadValidatorMetadata`` method as described under *Services*. This allows
you to define constraints for your object properties. It also works with
getters.
::
getters::
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints;
...
...
doc/services.rst
View file @
82e73deb
...
...
@@ -65,11 +65,11 @@ makes strong use of closures implements the ArrayAccess interface.
We will start off by creating a new instance of Pimple -- and
because ``Silex\Application`` extends ``Pimple`` all of this
applies to Silex as well
.
::
applies to Silex as well::
$container = new Pimple();
or
::
or::
$app = new Silex\Application();
...
...
@@ -82,12 +82,12 @@ an array key on the container::
$app['some_parameter'] = 'value';
The array key can be anything, by convention periods are
used for namespacing
.
::
used for namespacing::
$app['asset.host'] = 'http://cdn.mysite.com/';
Reading parameter values is possible with the same
syntax
.
::
syntax::
echo $app['some_parameter'];
...
...
@@ -97,9 +97,7 @@ Service definitions
Defining services is no different than defining parameters.
You just set an array key on the container to be a closure.
However, when you retrieve the service, the closure is executed.
This allows for lazy service creation.
::
This allows for lazy service creation::
$app['some_service'] = function () {
return new Service();
...
...
@@ -117,7 +115,7 @@ Shared services
You may want to use the same instance of a service across all
of your code. In order to do that you can make a *shared*
service
.
::
service::
$app['some_service'] = $app->share(function () {
return new Service();
...
...
@@ -134,7 +132,7 @@ from within a service definition closure. For example when
fetching services the current service depends on.
Because of this, the container is passed to the closure as
an argument
.
::
an argument::
$app['some_service'] = function ($app) {
return new Service($app['some_other_service'], $app['some_service.config']);
...
...
@@ -162,9 +160,7 @@ as a parameter, so that you can fetch it and execute it
yourself -- with your own arguments.
This is why Pimple allows you to protect your closures
from being executed, by using the ``protect`` method.
::
from being executed, by using the ``protect`` method::
$app['closure_parameter'] = $app->protect(function ($a, $b) {
return $a + $b;
...
...
doc/testing.rst
View file @
82e73deb
...
...
@@ -26,9 +26,7 @@ PHPUnit
is the de-facto standard testing framework for PHP. It was built for
writing unit tests, but it can be used for functional tests too. You write
tests by creating a new class, that extends the ``PHPUnit_Framework_TestCase``.
Your test cases are methods prefixed with ``test``.
::
Your test cases are methods prefixed with ``test``::
class ContactFormTest extends PHPUnit_Framework_TestCase
{
...
...
@@ -40,9 +38,7 @@ Your test cases are methods prefixed with ``test``.
In your test cases, you do assertions on the state of what you are testing. In
this case we are testing a contact form, so we would want to assert that the
page loaded correctly and contains our form.
::
page loaded correctly and contains our form::
public function testInitialPage()
{
...
...
doc/usage.rst
View file @
82e73deb
...
...
@@ -8,9 +8,7 @@ Bootstrap
To include the Silex all you need to do is require the ``silex.phar``
file and create an instance of ``Silex\Application``. After your
controller definitions, call the ``run`` method on your application.
::
controller definitions, call the ``run`` method on your application::
require_once __DIR__.'/silex.phar';
...
...
@@ -146,9 +144,7 @@ Example POST route
POST routes signify the creation of a resource. An example for this is a
feedback form. We will use `Swift Mailer
<http://swiftmailer.org/>`_ and assume a copy of it to be present in the
``vendor/swiftmailer`` directory.
::
``vendor/swiftmailer`` directory::
require_once __DIR__.'/vendor/swiftmailer/lib/swift_required.php';
...
...
@@ -193,9 +189,7 @@ Other methods
You can create controllers for most HTTP methods. Just call one of these
methods on your application: ``get``, ``post``, ``put``, ``delete``. You
can also call ``match``, which will match all methods.
::
can also call ``match``, which will match all methods::
$app->match('/blog', function () {
...
...
...
@@ -223,9 +217,7 @@ As has been show before you can define variable parts in a route like this::
});
It is also possible to have more than one variable part, just make sure the
closure arguments match the names of the variable parts.
::
closure arguments match the names of the variable parts::
$app->get('/blog/show/{postId}/{commentId}', function ($postId, $commentId) {
...
...
...
@@ -314,9 +306,7 @@ Default values
~~~~~~~~~~~~~~
You can define a default value for any route variable by calling ``value`` on
the ``Controller`` object.
::
the ``Controller`` object::
$app->get('/{pageName}', function ($pageName) {
...
...
...
@@ -332,9 +322,7 @@ Named routes
Certain extensions (such as ``UrlGenerator``) can make use of named routes.
By default Silex will generate a route name for you, that cannot really be
used. You can give a route a name by calling ``bind`` on the ``Controller``
object that is returned by the routing methods.
::
object that is returned by the routing methods::
$app->get('/', function () {
...
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment