Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docbot] Reviewed some component chapters #5550

Merged
merged 4 commits into from
Jul 28, 2015
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions components/class_loader/class_loader.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ The PSR-0 Class Loader
.. versionadded:: 2.1
The ``ClassLoader`` class was introduced in Symfony 2.1.

If your classes and third-party libraries follow the `PSR-0`_ standard, you
can use the :class:`Symfony\\Component\\ClassLoader\\ClassLoader` class to
load all of your project's classes.
If your classes and third-party libraries follow the `PSR-0`_ standard,
you can use the :class:`Symfony\\Component\\ClassLoader\\ClassLoader` class
to load all of your project's classes.

.. tip::

You can use both the ``ApcClassLoader`` and the ``XcacheClassLoader`` to
:doc:`cache </components/class_loader/cache_class_loader>` a ``ClassLoader``
You can use both the ``ApcClassLoader`` and the ``XcacheClassLoader``
to :doc:`cache </components/class_loader/cache_class_loader>` a ``ClassLoader``
instance or the ``DebugClassLoader`` to :doc:`debug </components/class_loader/debug_class_loader>`
it.

Expand All @@ -39,12 +39,12 @@ is straightforward::

.. note::

The autoloader is automatically registered in a Symfony application (see
``app/autoload.php``).
The autoloader is automatically registered in a Symfony application
(see ``app/autoload.php``).

Use the :method:`Symfony\\Component\\ClassLoader\\ClassLoader::addPrefix` or
:method:`Symfony\\Component\\ClassLoader\\ClassLoader::addPrefixes` methods to
register your classes::
Use the :method:`Symfony\\Component\\ClassLoader\\ClassLoader::addPrefix`
or :method:`Symfony\\Component\\ClassLoader\\ClassLoader::addPrefixes` methods
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think methods should be method @wouterj

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 (even though it's unrelated to the PR)

to register your classes::

// register a single namespaces
$loader->addPrefix('Symfony', __DIR__.'/vendor/symfony/symfony/src');
Expand All @@ -63,9 +63,9 @@ register your classes::
'Twig_' => __DIR__.'/vendor/twig/twig/lib',
));

Classes from a sub-namespace or a sub-hierarchy of `PEAR`_ classes can be looked
for in a location list to ease the vendoring of a sub-set of classes for large
projects::
Classes from a sub-namespace or a sub-hierarchy of `PEAR`_ classes can be
looked for in a location list to ease the vendoring of a sub-set of classes
for large projects::

$loader->addPrefixes(array(
'Doctrine\\Common' => __DIR__.'/vendor/doctrine/common/lib',
Expand All @@ -75,10 +75,10 @@ projects::
));

In this example, if you try to use a class in the ``Doctrine\Common`` namespace
or one of its children, the autoloader will first look for the class under the
``doctrine-common`` directory. If not found, it will then fallback to the default
``Doctrine`` directory (the last one configured) before giving up. The order
of the prefix registrations is significant in this case.
or one of its children, the autoloader will first look for the class under
the ``doctrine-common`` directory. If not found, it will then fallback to
the default ``Doctrine`` directory (the last one configured) before giving
up. The order of the prefix registrations is significant in this case.

.. _PEAR: http://pear.php.net/manual/en/standards.naming.php
.. _PSR-0: http://www.php-fig.org/psr/psr-0/
27 changes: 15 additions & 12 deletions components/class_loader/class_map_generator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
The Class Map Generator
=======================

Loading a class usually is an easy task given the `PSR-0`_ and `PSR-4`_ standards.
Thanks to the Symfony ClassLoader component or the autoloading mechanism provided
by Composer, you don't have to map your class names to actual PHP files manually.
Nowadays, PHP libraries usually come with autoloading support through Composer.
Loading a class usually is an easy task given the `PSR-0`_ and `PSR-4`_
standards. Thanks to the Symfony ClassLoader component or the autoloading
mechanism provided by Composer, you don't have to map your class names to
actual PHP files manually. Nowadays, PHP libraries usually come with autoloading
support through Composer.

But from time to time you may have to use a third-party library that comes
without any autoloading support and therefore forces you to load each class
Expand Down Expand Up @@ -44,16 +45,17 @@ it possible to create a map of class names to files.
Generating a Class Map
----------------------

To generate the class map, simply pass the root directory of your class files
to the :method:`Symfony\\Component\\ClassLoader\\ClassMapGenerator::createMap`
To generate the class map, simply pass the root directory of your class
files to the
:method:`Symfony\\Component\\ClassLoader\\ClassMapGenerator::createMap`
method::

use Symfony\Component\ClassLoader\ClassMapGenerator;

var_dump(ClassMapGenerator::createMap(__DIR__.'/library'));

Given the files and class from the table above, you should see an output like
this:
Given the files and class from the table above, you should see an output
like this:

.. code-block:: text

Expand Down Expand Up @@ -87,8 +89,9 @@ file in the same directory with the following contents::
'Acme\\Bar' => '/var/www/library/bar/Foo.php',
);

Instead of loading each file manually, you'll only have to register the generated
class map with, for example, the :class:`Symfony\\Component\\ClassLoader\\MapClassLoader`::
Instead of loading each file manually, you'll only have to register the
generated class map with, for example, the
:class:`Symfony\\Component\\ClassLoader\\MapClassLoader`::

use Symfony\Component\ClassLoader\MapClassLoader;

Expand All @@ -110,8 +113,8 @@ class map with, for example, the :class:`Symfony\\Component\\ClassLoader\\MapCla
component.

Besides dumping the class map for one directory, you can also pass an array
of directories for which to generate the class map (the result actually is
the same as in the example above)::
of directories for which to generate the class map (the result actually
is the same as in the example above)::

use Symfony\Component\ClassLoader\ClassMapGenerator;

Expand Down
8 changes: 4 additions & 4 deletions components/class_loader/debug_class_loader.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Debugging a Class Loader
.. versionadded:: 2.1
The ``DebugClassLoader`` class was introduced in Symfony 2.1.

The :class:`Symfony\\Component\\ClassLoader\\DebugClassLoader` attempts to
throw more helpful exceptions when a class isn't found by the registered
autoloaders. All autoloaders that implement a ``findFile()`` method are replaced
with a ``DebugClassLoader`` wrapper.
The :class:`Symfony\\Component\\ClassLoader\\DebugClassLoader` attempts
to throw more helpful exceptions when a class isn't found by the registered
autoloaders. All autoloaders that implement a ``findFile()`` method are
replaced with a ``DebugClassLoader`` wrapper.

Using the ``DebugClassLoader`` is as easy as calling its static
:method:`Symfony\\Component\\ClassLoader\\DebugClassLoader::enable` method::
Expand Down
8 changes: 5 additions & 3 deletions components/class_loader/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ Usage
-----

Whenever you reference a class that has not been required or included yet,
PHP uses the `autoloading mechanism`_ to delegate the loading of a file defining
the class. Symfony provides two autoloaders, which are able to load your classes:
PHP uses the `autoloading mechanism`_ to delegate the loading of a file
defining the class. Symfony provides two autoloaders, which are able to
load your classes:

* :doc:`/components/class_loader/class_loader`: loads classes that follow
the `PSR-0` class naming standard;
the `PSR-0`_ class naming standard;

* :doc:`/components/class_loader/map_class_loader`: loads classes using
a static map from class name to file path.
Expand All @@ -38,5 +39,6 @@ You can install the component in 2 different ways:

.. include:: /components/require_autoload.rst.inc

.. _PSR-0: http://www.php-fig.org/psr/psr-0/
.. _`autoloading mechanism`: http://php.net/manual/en/language.oop5.autoload.php
.. _Packagist: https://packagist.org/packages/symfony/class-loader
20 changes: 11 additions & 9 deletions components/class_loader/map_class_loader.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@
MapClassLoader
==============

The :class:`Symfony\\Component\\ClassLoader\\MapClassLoader` allows you to
autoload files via a static map from classes to files. This is useful if you
use third-party libraries which don't follow the `PSR-0`_ standards and so
can't use the :doc:`PSR-0 class loader </components/class_loader/class_loader>`.
The :class:`Symfony\\Component\\ClassLoader\\MapClassLoader` allows you
to autoload files via a static map from classes to files. This is useful
if you use third-party libraries which don't follow the `PSR-0`_ standards
and so can't use the
:doc:`PSR-0 class loader </components/class_loader/class_loader>`.

The ``MapClassLoader`` can be used along with the :doc:`PSR-0 class loader </components/class_loader/class_loader>`
by configuring and calling the ``register()`` method on both.
The ``MapClassLoader`` can be used along with the
:doc:`PSR-0 class loader </components/class_loader/class_loader>` by
configuring and calling the ``register()`` method on both.

.. note::

The default behavior is to append the ``MapClassLoader`` on the autoload
stack. If you want to use it as the first autoloader, pass ``true`` when
calling the ``register()`` method. Your class loader will then be prepended
on the autoload stack.
stack. If you want to use it as the first autoloader, pass ``true``
when calling the ``register()`` method. Your class loader will then
be prepended on the autoload stack.

Usage
-----
Expand Down
39 changes: 20 additions & 19 deletions components/config/caching.rst
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
.. index::
single: Config; Caching based on resources

Caching Based on Resources
Caching based on Resources
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the twisted logic behind title casing, but are we sure about this change?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah looks odd to me too (isn't "based" derived from "to base (sth. on sth.)"?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked odd to me at first, looks ok to me now - and I verified that lowercase makes sense from one quick source. Mostly, I don't care either way :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really get the feeling that we should think again about our capitalisation rule. :)

==========================

When all configuration resources are loaded, you may want to process the configuration
values and combine them all in one file. This file acts like a cache. Its
contents don’t have to be regenerated every time the application runs – only
when the configuration resources are modified.
When all configuration resources are loaded, you may want to process the
configuration values and combine them all in one file. This file acts
like a cache. Its contents don’t have to be regenerated every time the
application runs – only when the configuration resources are modified.

For example, the Symfony Routing component allows you to load all routes,
and then dump a URL matcher or a URL generator based on these routes. In
this case, when one of the resources is modified (and you are working in a
development environment), the generated file should be invalidated and regenerated.
This can be accomplished by making use of the :class:`Symfony\\Component\\Config\\ConfigCache`
class.

The example below shows you how to collect resources, then generate some code
based on the resources that were loaded, and write this code to the cache. The
cache also receives the collection of resources that were used for generating
the code. By looking at the "last modified" timestamp of these resources,
the cache can tell if it is still fresh or that its contents should be regenerated::
this case, when one of the resources is modified (and you are working
in a development environment), the generated file should be invalidated
and regenerated. This can be accomplished by making use of the
:class:`Symfony\\Component\\Config\\ConfigCache` class.

The example below shows you how to collect resources, then generate some
code based on the resources that were loaded and write this code to the
cache. The cache also receives the collection of resources that were used
for generating the code. By looking at the "last modified" timestamp of
these resources, the cache can tell if it is still fresh or that its contents
should be regenerated::

use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Config\Resource\FileResource;
Expand Down Expand Up @@ -52,8 +53,8 @@ the cache can tell if it is still fresh or that its contents should be regenerat
// you may want to require the cached code:
require $cachePath;

In debug mode, a ``.meta`` file will be created in the same directory as the
cache file itself. This ``.meta`` file contains the serialized resources,
whose timestamps are used to determine if the cache is still fresh. When not
in debug mode, the cache is considered to be "fresh" as soon as it exists,
In debug mode, a ``.meta`` file will be created in the same directory as
the cache file itself. This ``.meta`` file contains the serialized resources,
whose timestamps are used to determine if the cache is still fresh. When
not in debug mode, the cache is considered to be "fresh" as soon as it exists,
and therefore no ``.meta`` file will be generated.
Loading