11Introduction
22============
33
4- `Symfony2 `_ is a reusable set of standalone, decoupled, and cohesive PHP
4+ `Symfony `_ is a reusable set of standalone, decoupled and cohesive PHP
55components that solve common web development problems.
66
77Instead of using these low-level components, you can use the ready-to-be-used
8- Symfony2 full-stack web framework, which is based on these components... or
9- you can create your very own framework. This book is about the latter.
8+ Symfony full-stack web framework, which is based on these components... or
9+ you can create your very own framework. This tutorial is about the latter.
1010
11- Why would you like to create your own framework ?
11+ Why would you Like to Create your Own Framework ?
1212------------------------------------------------
1313
1414Why would you like to create your own framework in the first place? If you
@@ -18,7 +18,7 @@ creating your own altogether. Most of the time, they are right but there are
1818a few good reasons to start creating your own framework:
1919
2020* To learn more about the low level architecture of modern web frameworks in
21- general and about the Symfony2 full-stack framework internals in particular;
21+ general and about the Symfony full-stack framework internals in particular;
2222
2323* To create a framework tailored to your very specific needs (just be sure
2424 first that your needs are really specific);
@@ -34,55 +34,55 @@ a few good reasons to start creating your own framework:
3434
3535This tutorial will gently guide you through the creation of a web framework,
3636one step at a time. At each step, you will have a fully-working framework that
37- you can use as is or as a start for your very own. We will start with simple
38- frameworks and more features will be added with time. Eventually, you will have
37+ you can use as is or as a start for your very own. It will start with a simple
38+ framework and more features will be added with time. Eventually, you will have
3939a fully-featured full-stack web framework.
4040
4141And of course, each step will be the occasion to learn more about some of the
42- Symfony2 Components.
42+ Symfony Components.
4343
4444.. tip ::
4545
4646 If you don't have time to read the whole book, or if you want to get
4747 started fast, you can also have a look at `Silex `_, a micro-framework
48- based on the Symfony2 Components. The code is rather slim and it leverages
49- many aspects of the Symfony2 Components.
50-
51- Many modern web frameworks advertize themselves as being MVC frameworks. We
52- won't talk about the MVC pattern as the Symfony2 Components are able to create
53- any type of frameworks, not just the ones that follow the MVC architecture.
54- Anyway, if you have a look at the MVC semantics, this book is about how to
55- create the Controller part of a framework. For the Model and the View, it
56- really depends on your personal taste and you can use any existing
57- third-party libraries (Doctrine, Propel, or plain-old PDO for the Model; PHP
58- or Twig for the View).
48+ based on the Symfony Components. The code is rather slim and it leverages
49+ many aspects of the Symfony Components.
50+
51+ Many modern web frameworks advertize themselves as being MVC frameworks. This
52+ tutorial won't talk about the MVC pattern, as the Symfony Components are able to
53+ create any type of frameworks, not just the ones that follow the MVC
54+ architecture. Anyway, if you have a look at the MVC semantics, this book is
55+ about how to create the Controller part of a framework. For the Model and the
56+ View, it really depends on your personal taste and you can use any existing
57+ third-party libraries (Doctrine, Propel or plain-old PDO for the Model; PHP or
58+ Twig for the View).
5959
6060When creating a framework, following the MVC pattern is not the right goal. The
6161main goal should be the **Separation of Concerns **; this is probably the only
6262design pattern that you should really care about. The fundamental principles of
63- the Symfony2 Components are focused on the HTTP specification. As such, the
64- frameworks that we are going to create should be more accurately labelled as
65- HTTP frameworks or Request/Response frameworks .
63+ the Symfony Components are focused on the HTTP specification. As such, the
64+ framework that you are going to create should be more accurately labelled as a
65+ HTTP framework or Request/Response framework .
6666
67- Before we start
68- ---------------
67+ Before You Start
68+ ----------------
6969
7070Reading about how to create a framework is not enough. You will have to follow
71- along and actually type all the examples we will work on . For that, you need a
72- recent version of PHP (5.3.8 or later is good enough), a web server (like
73- Apache or NGinx ), a good knowledge of PHP and an understanding of Object
74- Oriented programming.
71+ along and actually type all the examples included in this tutorial . For that,
72+ you need a recent version of PHP (5.3.9 or later is good enough), a web server
73+ (like Apache, NGinx or PHP's built-in web server ), a good knowledge of PHP and
74+ an understanding of Object Oriented programming.
7575
76- Ready to go? Let's start.
76+ Ready to go? Read on!
7777
7878Bootstrapping
7979-------------
8080
81- Before we can even think of creating our first framework, we need to talk
82- about some conventions: where we will store our code, how we will name our
83- classes, how we will reference external dependencies, etc.
81+ Before you can even think of creating the first framework, you need to think
82+ about some conventions: where you will store the code, how you will name the
83+ classes, how you will reference external dependencies, etc.
8484
85- To store our framework, create a directory somewhere on your machine:
85+ To store your new framework, create a directory somewhere on your machine:
8686
8787.. code-block :: bash
8888
@@ -92,20 +92,9 @@ To store our framework, create a directory somewhere on your machine:
9292 Dependency Management
9393~~~~~~~~~~~~~~~~~~~~~
9494
95- To install the Symfony2 Components that we need for our framework, we are going
95+ To install the Symfony Components that you need for your framework, you are going
9696to use `Composer `_, a project dependency manager for PHP. If you don't have it
97- yet, `download and install `_ Composer now:
98-
99- .. code-block :: bash
100-
101- $ curl -sS https://getcomposer.org/installer | php
102-
103- Then, generate an empty ``composer.json `` file, where Composer will store the
104- framework dependencies:
105-
106- .. code-block :: bash
107-
108- $ composer init -n
97+ yet, :doc: `download and install Composer </cookbook/composer >` now.
10998
11099Our Project
111100-----------
@@ -114,16 +103,15 @@ Instead of creating our framework from scratch, we are going to write the same
114103"application" over and over again, adding one abstraction at a time. Let's
115104start with the simplest web application we can think of in PHP::
116105
117- <?php
118-
119106 // framework/index.php
120107
121108 $input = $_GET['name'];
122109
123110 printf('Hello %s', $input);
124111
125- Use the PHP built-in server to test this great application in a browser
126- (``http://localhost:4321/index.php?name=Fabien ``):
112+ If you have PHP 5.4, you can use the PHP built-in server to test this great
113+ application in a browser (``http://localhost:4321/index.php?name=Fabien ``).
114+ Otherwise, use your own server (Apache, Nginx, etc.):
127115
128116.. code-block :: bash
129117
@@ -132,8 +120,7 @@ Use the PHP built-in server to test this great application in a browser
132120 In the next chapter, we are going to introduce the HttpFoundation Component
133121and see what it brings us.
134122
135- .. _`Symfony2 ` : http://symfony.com/
123+ .. _`Symfony ` : http://symfony.com/
136124.. _`documentation` : http://symfony.com/doc
137125.. _`Silex` : http://silex.sensiolabs.org/
138126.. _`Composer` : http://packagist.org/about-composer
139- .. _`download and install` : https://getcomposer.org/doc/01-basic-usage.md
0 commit comments