@@ -20,40 +20,39 @@ Using the Finder Component
20
20
21
21
**1. ** If you're creating a new project, create a new empty directory for it.
22
22
23
- **2. ** Create a new file called `` composer.json `` and paste the following into it:
23
+ **2. ** Open a terminal and use Composer to grab the library.
24
24
25
- .. code-block :: json
25
+ .. code-block :: bash
26
26
27
- {
28
- "require" : {
29
- "symfony/finder" : " 2.3.*"
30
- }
31
- }
27
+ $ composer require symfony/finder
32
28
33
- If you already have a `` composer.json `` file, just add this line to it. You
34
- may also need to adjust the version (e.g. `` 2.2.2 `` or `` 2.3.* ``) .
29
+ The name `` symfony/finder `` is written at the top of the documentation for
30
+ whatever component you want .
35
31
36
- You can research the component names and versions at ` packagist.org `_.
32
+ .. tip ::
37
33
38
- **3. ** `Install composer `_ if you don't already have it present on your system:
34
+ If you get a command not found for ``composer ``, you'll need to
35
+ `Install composer `_. Depending on how you install, you may end up with
36
+ a ``composer.phar `` file in your directory. In that case, no worries!
37
+ Just run ``php composer.phar require symfony/finder ``.
39
38
40
- ** 4. ** Download the vendor libraries and generate the `` vendor/autoload.php `` file :
39
+ If you know you need a specific version of the library, add that to the command :
41
40
42
41
.. code-block :: bash
43
42
44
- $ php composer.phar install
43
+ $ composer require symfony/finder: ~ 2.3
45
44
46
- **5 . ** Write your code:
45
+ **3 . ** Write your code!
47
46
48
47
Once Composer has downloaded the component(s), all you need to do is include
49
48
the ``vendor/autoload.php `` file that was generated by Composer. This file
50
49
takes care of autoloading all of the libraries so that you can use them
51
50
immediately::
52
51
53
- // File: src/script.php
52
+ // File example : src/script.php
54
53
55
54
// update this to the path to the "vendor/" directory, relative to this file
56
- require_once '../vendor/autoload.php';
55
+ require_once __DIR__. '../vendor/autoload.php';
57
56
58
57
use Symfony\Component\Finder\Finder;
59
58
@@ -62,33 +61,18 @@ immediately::
62
61
63
62
// ...
64
63
65
- .. tip ::
66
-
67
- If you want to use all of the Symfony Components, then instead of adding
68
- them one by one:
64
+ Using all of the Components
65
+ ---------------------------
69
66
70
- .. code-block :: json
67
+ If you want to use all of the Symfony Components, then instead of adding
68
+ them one by one, you can include the ``symfony/symfony `` package:
71
69
72
- {
73
- "require" : {
74
- "symfony/finder" : " 2.3.*" ,
75
- "symfony/dom-crawler" : " 2.3.*" ,
76
- "symfony/css-selector" : " 2.3.*"
77
- }
78
- }
79
-
80
- you can use:
81
-
82
- .. code-block :: json
70
+ .. code-block :: bash
83
71
84
- {
85
- "require" : {
86
- "symfony/symfony" : " 2.3.*"
87
- }
88
- }
72
+ $ composer require symfony/symfony
89
73
90
- This will include the Bundle and Bridge libraries, which you may not
91
- actually need.
74
+ This will also include the Bundle and Bridge libraries, which you may or
75
+ may not actually need.
92
76
93
77
Now what?
94
78
---------
@@ -100,4 +84,3 @@ And have fun!
100
84
101
85
.. _Composer : http://getcomposer.org
102
86
.. _Install composer : http://getcomposer.org/download/
103
- .. _packagist.org : https://packagist.org/
0 commit comments