Skip to content

Commit de1e7db

Browse files
gajdawweaverryan
authored andcommitted
How to use components
1 parent ce278ab commit de1e7db

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

cookbook/workflow/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ Workflow
66

77
new_project_git
88
new_project_svn
9+
new_project_components
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
.. index::
2+
single: Workflow; Components
3+
4+
How to start a new project using Symfony2 Components
5+
====================================================
6+
7+
Using Finder Component
8+
----------------------
9+
10+
1. Create a new empty folder.
11+
12+
2. Create a new file called ``composer.json`` and paste the following into it:
13+
14+
.. code-block:: json
15+
16+
{
17+
"require": {
18+
"symfony/finder": "2.1.*"
19+
}
20+
}
21+
22+
3. Download vendor libraries and generate ``vendor/autoload.php`` file:
23+
24+
.. code-block:: bash
25+
26+
$ php composer.phar install
27+
28+
4. Write your code:
29+
30+
.. code-block:: php
31+
32+
<?php
33+
34+
// File: src/script.php
35+
36+
require_once '../vendor/autoload.php';
37+
38+
use Symfony\Component\Finder\Finder;
39+
40+
$finder = new Finder();
41+
$finder->in('../data/');
42+
43+
...
44+
45+
.. tip::
46+
47+
If you want to use all the Symfony2 Component, then instead of adding them one by one:
48+
49+
.. code-block:: json
50+
51+
{
52+
"require": {
53+
"symfony/finder": "2.1.*",
54+
"symfony/dom-crawler": "2.1.*",
55+
"symfony/css-selector": "2.1.*"
56+
...
57+
}
58+
}
59+
60+
use:
61+
62+
.. code-block:: json
63+
64+
{
65+
"require": {
66+
"symfony/symfony": "2.1.*"
67+
}
68+
}

0 commit comments

Comments
 (0)