-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Changing description of symfony installation to composer #1993
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 |
---|---|---|
|
@@ -420,34 +420,29 @@ Why should you have to reinvent solutions to all these routine problems? | |
Add a Touch of Symfony2 | ||
~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
Symfony2 to the rescue. Before actually using Symfony2, you need to make | ||
sure PHP knows how to find the Symfony2 classes. This is accomplished via | ||
an autoloader that Symfony provides. An autoloader is a tool that makes it | ||
possible to start using PHP classes without explicitly including the file | ||
containing the class. | ||
Symfony2 to the rescue. Before actually using Symfony2, you need to download | ||
it. This can be done by using composer, which takes care of downloading the | ||
correct version and all it's dependencies and provides an autoloader. An | ||
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.
|
||
autoloader is a tool that makes it possible to start using PHP classes | ||
without explicitly including the file containing the class. | ||
|
||
First, `download Symfony`_ and place it into a ``vendor/symfony/symfony/`` directory. | ||
Next, create an ``app/bootstrap.php`` file. Use it to ``require`` the two | ||
files in the application and to configure the autoloader: | ||
In your root directory, create a ``composer.json`` file with the following | ||
content: | ||
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 like this method, the recommend way to start a symfony project is:
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 was under the impression that in this part of the docs, only the symfony core is used, not the full-stack framework? 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. Yep, that's right - we're actually only need a few specific components, but of course we're not teaching Composer or those finer details, so I like how you've bright in |
||
|
||
.. code-block:: html+php | ||
|
||
<?php | ||
// bootstrap.php | ||
require_once 'model.php'; | ||
require_once 'controllers.php'; | ||
require_once 'vendor/symfony/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php'; | ||
.. code-block:: json | ||
|
||
$loader = new Symfony\Component\ClassLoader\UniversalClassLoader(); | ||
$loader->registerNamespaces(array( | ||
'Symfony' => __DIR__.'/../vendor/symfony/symfony/src', | ||
)); | ||
|
||
$loader->register(); | ||
|
||
This tells the autoloader where the ``Symfony`` classes are. With this, you | ||
can start using Symfony classes without using the ``require`` statement for | ||
the files that contain them. | ||
{ | ||
"require": { | ||
"symfony/symfony": "2.1.*" | ||
}, | ||
"autoload": { | ||
"files": ["model.php","controller.php"] | ||
} | ||
} | ||
|
||
After installing your dependencies, composer has generated ``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. capitalize 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. And yes, I see what you're saying now about how much of the Composer details to actually have here. I would say something like:
|
||
which takes care to include all files from the symfony framework as well as | ||
the files mentioned in the autoload section of your composer.json. | ||
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. Wrap
|
||
|
||
Core to Symfony's philosophy is the idea that an application's main job is | ||
to interpret each request and return a response. To this end, Symfony2 provides | ||
|
@@ -460,7 +455,7 @@ the HTTP response being returned. Use them to improve the blog: | |
|
||
<?php | ||
// index.php | ||
require_once 'app/bootstrap.php'; | ||
require_once 'vendor/bootstrap.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. Just starting w/symfony. Right now at this part in the book. Got set with composer as shown. No vendor/bootstrap.php was created, only vendor/autoload.php. I made a bootstrap from https://github.com/ruian/RuianSeoBundle/blob/master/vendor/bootstrap.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. 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. Hey, thanks. Your reply means a lot. On first look symfony looks friendly On Sat, Jan 19, 2013 at 1:02 AM, Wouter J notifications@github.com wrote:
|
||
|
||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
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.
Composer
- capitalC