-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[WIP][Cookbook] Document how to install 3th party bundles #2404
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ Bundles | |
override | ||
remove | ||
extension | ||
installation |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
.. index:: | ||
single: Bundle; Installation | ||
|
||
How to install 3rd party bundles | ||
================================ | ||
|
||
Most bundles provide a documentation of installation. However, most | ||
steps are common for any bundle. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. However the basic steps for installing a bundle are the same. |
||
|
||
Add composer dependencies | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 3 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it should be dashed |
||
|
||
Starting from Symfony2.1 dependencies are managed via Composer. It's | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
a good idea to learn some basics of Composer here: | ||
http://getcomposer.org/doc/00-intro.md. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if this works. I suggest something like: a good idea to learn some basics of Composer in `their documentation`_
// add the bottom of this file:
.. `their documentation`: http://getcomposer.org/doc/00-intro.md |
||
|
||
Before you can use composer to install a bundle you should look for a | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
`Packagist`_ package of that bundle. For example, for the | ||
`FOSUserBundle`_ you should look for a | ||
``friendsofsymfony/user-bundle`` package and it does exists: | ||
https://packagist.org/packages/friendsofsymfony/user-bundle. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we get some conflict with the dot here. Add a space between the link and the dot |
||
|
||
.. note:: | ||
|
||
Packagist is the main archive for Composer. If you are searching | ||
for a bundle, the best thing you can do is check out | ||
`KnpBundles`_, it is the unofficial achive of Symfony Bundles. If | ||
a bundle contains a README file, it is displayed there and if it | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please put |
||
has a Packagist package it shows a link to the package. It's a | ||
really usefull site to begin searching for bundles. | ||
|
||
Now you have the package name, you should determine the version you | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that you |
||
want to use. Usually different versions of a bundle correspond to a | ||
particular version of Symfony, this should be in the README file (in | ||
the Package, which you can view on Github or KnpBundles). If it isn't | ||
in the README, you can use the version you want. In the case of | ||
FOSUserBundle README file has a caution that version 1.2.0 must be | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
used for Symfony2.0 and 1.3 for Symfony2.1+. Let's use development | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's use the development version There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a standard to not use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I'm not a native speaker I rely on you guys here. Please suggest something here. |
||
version for this exmaple. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo should say example instead of exmaple |
||
|
||
Now we can add the bundle to our composer.json file and update the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please put |
||
dependencies. You can do this manually: | ||
|
||
1. **Add it to the ``composer.json`` file:** | ||
|
||
.. code-block:: javascript | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
{ | ||
..., | ||
"require": { | ||
..., | ||
"friendsofsymfony/user-bundle": "dev-master" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This conflict with the fact that you mention 1.3 above. FOSUserBundle dev-master is not 1.3 but 2.0.x-dev And please don't advocate the So here, you should be requiring either There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Btw, Packagist uses the branch alias when displaying the require statement for the package version when it exists. |
||
} | ||
} | ||
|
||
2. **Update the dependency:** | ||
|
||
.. code-block:: bash | ||
|
||
$ php composer.phar update friendsofsymfony/user-bundle | ||
|
||
or update all dependencies | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should not get indented There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But it should be under the '2.' list element. Shouldn't it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, wait you used list items :) I would suggest to drop the list items and use something like we did in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to make it like in
In reality examples 1 and 2 are grouped. But its hard to determine it visually (only capital Or points to that). I guess that initial formatting is easier to read. What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's good right now. When it's merged we can see how it looks on the site and change it to make it more clear |
||
|
||
.. code-block:: bash | ||
|
||
$ php composer.phar update | ||
|
||
Or you can do this in one command: | ||
|
||
.. code-block:: bash | ||
|
||
$ php composer.phar require friendsofsymfony/user-bundle:dev-master | ||
|
||
Enable the bundle | ||
~~~~~~~~~~~~~~~~~ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dashes as well |
||
|
||
Now the bundle is installed into our Symfony project (in | ||
vendor/friendsofsymfony/) and the autoloader recognises this | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. an inline code block here too |
||
bundle. The only thing we need to do now is registering the bundle in | ||
the AppKernel: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please end the sentence with a double colon and remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't get what you mean in the second comment here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of: the ``AppKernel``:
.. code-block:: php
// ... some nice PHP code I prefer this: the ``AppKernel``::
// ... some nice PHP code here |
||
|
||
.. code-block:: php | ||
|
||
// app/AppKernel.php | ||
|
||
// ... | ||
class AppKernel extends Kernel | ||
{ | ||
// ... | ||
|
||
public function registerBundles() | ||
{ | ||
$bundles = array( | ||
..., | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you should use |
||
new FOS\UserBundle\FOSUserBundle(), | ||
); | ||
|
||
// ... | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. some very big indentation issues here |
||
|
||
Configure the bundle | ||
~~~~~~~~~~~~~~~~~~~~ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dashes... ;-) |
||
|
||
Usually bundles require some configuration to be added to app's | ||
app/config/config.yml file. Bundle's documentation will likely | ||
describe that configuration. But you can also get a reference of the | ||
bundle's config via ``config:dump-reference`` command. | ||
|
||
For instance, in order to look the reference of the assetic config we | ||
can use this: | ||
|
||
.. code-block:: bash | ||
|
||
$ app/console config:dump-reference AsseticBundle | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice i did not know this trick |
||
|
||
or this: | ||
|
||
.. code-block:: bash | ||
|
||
$ app/console config:dump-reference assetic | ||
|
||
The output will look like this: | ||
|
||
.. code-block:: text | ||
|
||
assetic: | ||
debug: %kernel.debug% | ||
use_controller: | ||
enabled: %kernel.debug% | ||
profiler: false | ||
read_from: %kernel.root_dir%/../web | ||
write_to: %assetic.read_from% | ||
java: /usr/bin/java | ||
node: /usr/local/bin/node | ||
node_paths: [] | ||
... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you should use |
||
|
||
.. _Packagist: https://packagist.org | ||
.. _FOSUserBundle: https://github.com/FriendsOfSymfony/FOSUserBundle | ||
.. _KnpBundles: http://knpbundles.com/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most bundles provide their own installation instructions.