-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Updating component usage to use composer require #4425
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 all commits
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 |
---|---|---|
|
@@ -20,40 +20,39 @@ Using the Finder Component | |
|
||
**1.** If you're creating a new project, create a new empty directory for it. | ||
|
||
**2.** Create a new file called ``composer.json`` and paste the following into it: | ||
**2.** Open a terminal and use Composer to grab the library. | ||
|
||
.. code-block:: json | ||
.. code-block:: bash | ||
|
||
{ | ||
"require": { | ||
"symfony/finder": "2.3.*" | ||
} | ||
} | ||
$ composer require symfony/finder | ||
|
||
If you already have a ``composer.json`` file, just add this line to it. You | ||
may also need to adjust the version (e.g. ``2.2.2`` or ``2.3.*``). | ||
The name ``symfony/finder`` is written at the top of the documentation for | ||
whatever component you want. | ||
|
||
You can research the component names and versions at `packagist.org`_. | ||
.. tip:: | ||
|
||
**3.** `Install composer`_ if you don't already have it present on your system: | ||
If you get a command not found for ``composer``, you'll need to | ||
`Install composer`_. Depending on how you install, you may end up with | ||
a ``composer.phar`` file in your directory. In that case, no worries! | ||
Just run ``php composer.phar require symfony/finder``. | ||
|
||
**4.** Download the vendor libraries and generate the ``vendor/autoload.php`` file: | ||
If you know you need a specific version of the library, add that to the command: | ||
|
||
.. code-block:: bash | ||
|
||
$ php composer.phar install | ||
$ composer require symfony/finder:~2.3 | ||
|
||
**5.** Write your code: | ||
**3.** Write your code! | ||
|
||
Once Composer has downloaded the component(s), all you need to do is include | ||
the ``vendor/autoload.php`` file that was generated by Composer. This file | ||
takes care of autoloading all of the libraries so that you can use them | ||
immediately:: | ||
|
||
// File: src/script.php | ||
// File example: src/script.php | ||
|
||
// update this to the path to the "vendor/" directory, relative to this file | ||
require_once '../vendor/autoload.php'; | ||
require_once __DIR__.'../vendor/autoload.php'; | ||
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. missing 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. ah thanks, fixed at sha: ddd4a3b |
||
|
||
use Symfony\Component\Finder\Finder; | ||
|
||
|
@@ -62,33 +61,18 @@ immediately:: | |
|
||
// ... | ||
|
||
.. tip:: | ||
|
||
If you want to use all of the Symfony Components, then instead of adding | ||
them one by one: | ||
Using all of the Components | ||
--------------------------- | ||
|
||
.. code-block:: json | ||
If you want to use all of the Symfony Components, then instead of adding | ||
them one by one, you can include the ``symfony/symfony`` package: | ||
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 know we had this before, but I'm not sure if we should really keep it. 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. I'm -1 for it too, as I already made clear in the PR added 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. On the other hand, it'll be quicker... (we do this in the tests of the CMF for instance, while we never use everything in our tests) |
||
|
||
{ | ||
"require": { | ||
"symfony/finder": "2.3.*", | ||
"symfony/dom-crawler": "2.3.*", | ||
"symfony/css-selector": "2.3.*" | ||
} | ||
} | ||
|
||
you can use: | ||
|
||
.. code-block:: json | ||
.. code-block:: bash | ||
|
||
{ | ||
"require": { | ||
"symfony/symfony": "2.3.*" | ||
} | ||
} | ||
$ composer require symfony/symfony | ||
|
||
This will include the Bundle and Bridge libraries, which you may not | ||
actually need. | ||
This will also include the Bundle and Bridge libraries, which you may or | ||
may not actually need. | ||
|
||
Now what? | ||
--------- | ||
|
@@ -100,4 +84,3 @@ And have fun! | |
|
||
.. _Composer: http://getcomposer.org | ||
.. _Install composer: http://getcomposer.org/download/ | ||
.. _packagist.org: https://packagist.org/ |
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.
Shouldn't we explain how to require a certain version of a package?
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.
yes, 👍