Changeset 6118
- Timestamp:
- 11/20/07 13:32:24 (1 year ago)
- Files:
-
- doc/branches/1.0/book/01-Introducing-Symfony.txt (modified) (2 diffs)
- doc/branches/1.0/book/03-Running-Symfony.txt (modified) (3 diffs)
- doc/branches/1.0/book/06-Inside-the-Controller-Layer.txt (modified) (2 diffs)
- doc/branches/1.0/book/07-Inside-the-View-Layer.txt (modified) (2 diffs)
- doc/branches/1.0/book/08-Inside-the-Model-Layer.txt (modified) (2 diffs)
- doc/branches/1.0/book/09-Links-and-the-Routing-System.txt (modified) (1 diff)
- doc/branches/1.0/book/14-Generators.txt (modified) (1 diff)
- doc/branches/1.0/book/15-Unit-and-Functional-Testing.txt (modified) (1 diff)
- doc/branches/1.0/book/17-Extending-Symfony.txt (modified) (4 diffs)
- doc/branches/1.0/book/18-Performance.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
doc/branches/1.0/book/01-Introducing-Symfony.txt
r5219 r6118 70 70 ### The Symfony Community 71 71 72 As soon as the symfony website ([http://www.symfony-project. com/](http://www.symfony-project.com/)) was launched, numerous developers from around the world downloaded and installed the framework, read the online documentation, and built their first application with symfony, and the buzz began to mount.72 As soon as the symfony website ([http://www.symfony-project.org/](http://www.symfony-project.org/)) was launched, numerous developers from around the world downloaded and installed the framework, read the online documentation, and built their first application with symfony, and the buzz began to mount. 73 73 74 74 Web application frameworks were getting popular at that time, and the need for a full-featured framework in PHP was high. Symfony offered a compelling solution due to its impressive code quality and significant amount of documentation--two major advantages over the other players in the framework category. Contributors soon began to surface, proposing patches and enhancements, proofreading the documentation, and performing other much-needed roles. … … 205 205 Symfony is the perfect tool for RAD. As a matter of fact, the framework was built by a web agency applying the RAD principle for its own projects. This means that learning to use symfony is not about learning a new language, but more about applying the right reflexes and the best judgment in order to build applications in a more effective way. 206 206 207 The symfony project website proposes a step-by-step tutorial illustrating the development of an application in an agile way. It is called askeet ([http://www.symfony-project. com/askeet](http://www.symfony-project.com/askeet)), and is recommended reading for those who want to learn more about agile development.207 The symfony project website proposes a step-by-step tutorial illustrating the development of an application in an agile way. It is called askeet ([http://www.symfony-project.org/askeet](http://www.symfony-project.org/askeet)), and is recommended reading for those who want to learn more about agile development. 208 208 209 209 ### YAML doc/branches/1.0/book/03-Running-Symfony.txt
r3865 r6118 21 21 The sandbox is a simple archive of files. It contains an empty symfony project including all the required libraries (symfony, pake, lime, Creole, Propel, and Phing), a default application, and basic configuration. It will work out of the box, without specific server configuration or any additional packages. 22 22 23 To install it, download the sandbox archive from [http://www.symfony-project. com/get/sf_sandbox.tgz](http://www.symfony-project.com/get/sf_sandbox.tgz). Unpack it under the root web directory configured for your server (usually `web/` or `www/`). For the purposes of uniformity, this chapter will assume you unpacked it to the directory `sf_sandbox/`.23 To install it, download the sandbox archive from [http://www.symfony-project.org/get/sf_sandbox.tgz](http://www.symfony-project.org/get/sf_sandbox.tgz). Unpack it under the root web directory configured for your server (usually `web/` or `www/`). For the purposes of uniformity, this chapter will assume you unpacked it to the directory `sf_sandbox/`. 24 24 25 25 >**CAUTION** … … 317 317 >Symfony is compatible with other server configurations. You can, for instance, access a symfony application using an alias instead of a virtual host. You can also run a symfony application with an IIS server. There are as many techniques as there are configurations, and it is not the purpose of this book to explain them all. 318 318 > 319 >To find directions for a specific server configuration, refer to the symfony wiki ([http:// www.symfony-project.com/trac/wiki](http://www.symfony-project.com/trac/wiki)), which contains many step-by-step tutorials.319 >To find directions for a specific server configuration, refer to the symfony wiki ([http://trac.symfony-project.com/](http://trac.symfony-project.com/)), which contains many step-by-step tutorials. 320 320 321 321 Troubleshooting … … 354 354 You can check if your problem has already happened to someone else and find solutions in various places: 355 355 356 * The symfony installation forum ([http://www.symfony-project. com/forum/](http://www.symfony-project.com/forum/)) is full of installation questions about a given platform, environment, configuration, host, and so on.356 * The symfony installation forum ([http://www.symfony-project.org/forum/](http://www.symfony-project.org/forum/)) is full of installation questions about a given platform, environment, configuration, host, and so on. 357 357 * The archives of the users mailing-list ([http://groups.google.fr/group/symfony-users](http://groups.google.fr/group/symfony-users)) are also searchable. You may find similar experiences to your own there. 358 * The symfony wiki ([http:// www.symfony-project.com/trac/wiki#Installingsymfony](http://www.symfony-project.com/trac/wiki#Installingsymfony)) contains step-by-step tutorials, contributed by symfony users, about installation.358 * The symfony wiki ([http://trac.symfony-project.com/#Installingsymfony](http://trac.symfony-project.com/#Installingsymfony)) contains step-by-step tutorials, contributed by symfony users, about installation. 359 359 360 360 If you don't find any answer, try posing your question to the symfony community. You can post your query in the forum, the mailing list, or even drop to the `#symfony` IRC channel to get feedback from the most active members of the community. doc/branches/1.0/book/06-Inside-the-Controller-Layer.txt
r5368 r6118 768 768 769 769 >**TIP** 770 >Among the symfony plug-ins, the `sfGuardPlugin` (http:// www.symfony-project.com/trac/wiki/sfGuardPlugin) extends the session class to make login and logout easy. Refer to Chapter 17 for more information.770 >Among the symfony plug-ins, the `sfGuardPlugin` (http://trac.symfony-project.com/wiki/sfGuardPlugin) extends the session class to make login and logout easy. Refer to Chapter 17 for more information. 771 771 772 772 ### Complex Credentials … … 1051 1051 } 1052 1052 1053 Filters are used extensively in plug-ins, as they allow you to extend the features of an application globally. Refer to Chapter 17 to learn more about plug-ins, and see the online wiki ([http:// www.symfony-project.com/trac/wiki](http://www.symfony-project.com/trac/wiki)) for more filter examples.1053 Filters are used extensively in plug-ins, as they allow you to extend the features of an application globally. Refer to Chapter 17 to learn more about plug-ins, and see the online wiki ([http://trac.symfony-project.com/](http://trac.symfony-project.com/)) for more filter examples. 1054 1054 1055 1055 Module Configuration doc/branches/1.0/book/07-Inside-the-View-Layer.txt
r4907 r6118 45 45 } 46 46 47 As a matter of fact, the `input_tag()` function built into symfony is a little more complicated than that, as it accepts a third parameter to add other attributes to the `<input>` tag. You can check its complete syntax and options in the online API documentation ([http://www.symfony-project. com/api/symfony.html](http://www.symfony-project.com/api/symfony.html)).47 As a matter of fact, the `input_tag()` function built into symfony is a little more complicated than that, as it accepts a third parameter to add other attributes to the `<input>` tag. You can check its complete syntax and options in the online API documentation ([http://www.symfony-project.org/api/symfony.html](http://www.symfony-project.org/api/symfony.html)). 48 48 49 49 Most of the time, helpers carry intelligence and save you long and complex coding: … … 119 119 => <link href="/stylesheets/style.css" media="screen" rel="stylesheet"type="text/css" /> 120 120 121 There are many other helpers in symfony, and it would take a full book to describe all of them. The best reference for helpers is the online API documentation ([http:// www.symfony-project. com/api/symfony.html](http://www.symfony-project.com/api/symfony.html)), where all the helpers are well documented, with their syntax, options, and examples.121 There are many other helpers in symfony, and it would take a full book to describe all of them. The best reference for helpers is the online API documentation ([http:// www.symfony-project.org/api/symfony.html](http://www.symfony-project.org/api/symfony.html)), where all the helpers are well documented, with their syntax, options, and examples. 122 122 123 123 #### Adding Your Own Helpers doc/branches/1.0/book/08-Inside-the-Model-Layer.txt
r4907 r6118 406 406 407 407 >**TIP** 408 >When a `doSelect()` query returns a large number of results, you might want to display only a subset of it in your response. Symfony provides a pager class called sfPropelPager, which automates the pagination of results. Check the pager documentation at [http://www.symfony-project. com/cookbook/trunk/pager](http://www.symfony-project.com/cookbook/trunk/pager) for more information and usage examples.408 >When a `doSelect()` query returns a large number of results, you might want to display only a subset of it in your response. Symfony provides a pager class called sfPropelPager, which automates the pagination of results. Check the pager documentation at [http://www.symfony-project.org/cookbook/trunk/pager](http://www.symfony-project.org/cookbook/trunk/pager) for more information and usage examples. 409 409 410 410 ### Using Raw SQL Queries … … 638 638 After rebuilding the model, deleted `Article` objects will remain in the database, invisible to the queries using the ORM, unless you temporarily disable the behavior with `sfPropelParanoidBehavior::disable()`. 639 639 640 Check the list of symfony plug-ins in the wiki to find behaviors ([http:// www.symfony-project.com/trac/wiki/SymfonyPlugins#Propelbehaviorplugins](http://www.symfony-project.com/trac/wiki/SymfonyPlugins#Propelbehaviorplugins)). Each has its own documentation and installation guide.640 Check the list of symfony plug-ins in the wiki to find behaviors ([http://trac.symfony-project.com/wiki/SymfonyPlugins#Propelbehaviorplugins](http://trac.symfony-project.com/wiki/SymfonyPlugins#Propelbehaviorplugins)). Each has its own documentation and installation guide. 641 641 642 642 Extended Schema Syntax doc/branches/1.0/book/09-Links-and-the-Routing-System.txt
r4907 r6118 621 621 ); 622 622 623 The sfRouting singleton has other useful methods for handling routes by hand: `clearRoutes()`, `hasRoutes()`, `getRoutesByName()`, and so on. Refer to the API documentation ([http://www.symfony-project. com/api/symfony.html](http://www.symfony-project.com/api/symfony.html)) to learn more.623 The sfRouting singleton has other useful methods for handling routes by hand: `clearRoutes()`, `hasRoutes()`, `getRoutesByName()`, and so on. Refer to the API documentation ([http://www.symfony-project.org/api/symfony.html](http://www.symfony-project.org/api/symfony.html)) to learn more. 624 624 625 625 >**TIP** doc/branches/1.0/book/14-Generators.txt
r4907 r6118 299 299 ----------------------- 300 300 301 The generator configuration file is very powerful, allowing you to alter the generated administration in many ways. But such capabilities come with a price: The overall syntax description is long to read and learn, making this chapter one of the longest in this book. The symfony website proposes an additional resource that will help you learn this syntax: the administration generator cheat sheet, reproduced in Figure 14-7. Download it from [http://www.symfony-project. com/uploads/assets/sfAdminGeneratorRefCard.pdf](http://www.symfony-project.com/uploads/assets/sfAdminGeneratorRefCard.pdf), and keep it close to you when you read the following examples of this chapter.301 The generator configuration file is very powerful, allowing you to alter the generated administration in many ways. But such capabilities come with a price: The overall syntax description is long to read and learn, making this chapter one of the longest in this book. The symfony website proposes an additional resource that will help you learn this syntax: the administration generator cheat sheet, reproduced in Figure 14-7. Download it from [http://www.symfony-project.org/uploads/assets/sfAdminGeneratorRefCard.pdf](http://www.symfony-project.org/uploads/assets/sfAdminGeneratorRefCard.pdf), and keep it close to you when you read the following examples of this chapter. 302 302 303 303 The examples of this section will tweak the `article` administration module, as well as the `comment` administration module, based on the `Comment` class definition. Create the latter with the `propel-init-admin` task: doc/branches/1.0/book/15-Unit-and-Functional-Testing.txt
r5341 r6118 13 13 Automated tests can sometimes replace developer documentation since they can clearly illustrate what an application is supposed to do. A good test suite shows what output should be expected for a set of test inputs, and that is a good way to explain the purpose of a method. 14 14 15 The symfony framework applies this principle to itself. The internals of the framework are validated by automated tests. These unit and functional tests are not bundled with the standard symfony distribution, but you can check them out from the SVN repository or browse them online at [http:// www.symfony-project.com/trac/browser/trunk/test](http://www.symfony-project.com/trac/browser/trunk/test).15 The symfony framework applies this principle to itself. The internals of the framework are validated by automated tests. These unit and functional tests are not bundled with the standard symfony distribution, but you can check them out from the SVN repository or browse them online at [http://trac.symfony-project.com/browser/trunk/test](http://trac.symfony-project.org/browser/trunk/test). 16 16 17 17 ### Unit and Functional Tests doc/branches/1.0/book/17-Extending-Symfony.txt
r4907 r6118 326 326 >The Propel objects corresponding to the tables of the database all have a delete() method, which deletes the related record from the database. But for an `Invoice` class, for which you can't delete a record, you may want to alter the `delete()` method to be able to keep the record in the database and change the value of an is_deleted attribute to true instead. Usual object retrieval methods (`doSelect()`, `retrieveByPk()`) would only consider the records for which `is_deleted` is false. You would also need to add another method called `forceDelete()`, which would allow you to really delete the record. In fact, all these modifications can be packaged into a new class, called `ParanoidBehavior`. The final `Invoice` class extends the Propel `BaseInvoice` class and has methods of the `ParanoidBehavior` mixed in. 327 327 > 328 >So a behavior is a mixin on a Propel object. Actually, the term "behavior" in symfony covers one more thing: the fact that the mixin is packaged as a plug-in. The `ParanoidBehavior` class just mentioned corresponds to a real symfony plug-in called `sfPropelParanoidBehaviorPlugin`. Refer to the symfony wiki ([http:// www.symfony-project.com/trac/wiki/sfPropelParanoidBehaviorPlugin](http://www.symfony-project.com/trac/wiki/sfPropelParanoidBehaviorPlugin)) for details on installation and use of this plug-in.328 >So a behavior is a mixin on a Propel object. Actually, the term "behavior" in symfony covers one more thing: the fact that the mixin is packaged as a plug-in. The `ParanoidBehavior` class just mentioned corresponds to a real symfony plug-in called `sfPropelParanoidBehaviorPlugin`. Refer to the symfony wiki ([http://trac.symfony-project.com/wiki/sfPropelParanoidBehaviorPlugin](http://trac.symfony-project.com/wiki/sfPropelParanoidBehaviorPlugin)) for details on installation and use of this plug-in. 329 329 > 330 330 >One last word about behaviors: To be able to support them, the generated Propel objects must contain quite a number of hooks. These may slow down execution a little and penalize performance if you don't use behaviors. That's why the hooks are not enabled by default. In order to add them and enable behavior support, you must first set the `propel.builder.addBehaviors` property to `true` in the `propel.ini` file and rebuild the model. … … 450 450 The symfony project website contains a page dedicated to symfony plug-ins. It is in the symfony wiki and accessible with the following URL: 451 451 452 http:// www.symfony-project.com/trac/wiki/SymfonyPlugins452 http://trac.symfony-project.com/wiki/SymfonyPlugins 453 453 454 454 Each plug-in listed there has its own page, with detailed installation instructions and documentation. … … 794 794 <api>stable</api> 795 795 </stability> 796 <license uri="http://www.symfony-project. com/license">MIT license</license>796 <license uri="http://www.symfony-project.org/license">MIT license</license> 797 797 <notes>-</notes> 798 798 <contents> … … 946 946 A symfony plug-in gets the broadest audience when distributed by the `symfony-project.com` website. Even your own plug-ins can be distributed this way, provided that you follow these steps: 947 947 948 1. Make sure the `README` file describes the way to install and use your plug-in, and that the `LICENSE` file gives the license details. Format your `README` with the Wiki Formatting syntax ([http:// www.symfony-project.com/trac/wiki/WikiFormatting](http://www.symfony-project.com/trac/wiki/WikiFormatting)).948 1. Make sure the `README` file describes the way to install and use your plug-in, and that the `LICENSE` file gives the license details. Format your `README` with the Wiki Formatting syntax ([http://trac.symfony-project.com/wiki/WikiFormatting](http://trac.symfony-project.com/wiki/WikiFormatting)). 949 949 2. Create a PEAR package for your plug-in by calling the `pear package` command, and test it. The PEAR package must be named `sfSamplePlugin-1.0.0.tgz` (1.0.0 is the plug-in version). 950 950 3. Create a new page on the symfony wiki named `sfSamplePlugin` (`Plugin` is a mandatory suffix). In this page, describe the plug-in usage, the license, the dependencies, and the installation procedure. You can reuse the contents of the plug-in `README` file. Check the existing plug-ins' wiki pages and use them as an example. 951 951 4. Attach your PEAR package to the wiki page (`sfSamplePlugin-1.0.0.tgz`). 952 5. Add the new plug-in wiki page (`[wiki:sfSamplePlugin]`) to the list of available plug-ins, which is also a wiki page ([http:// www.symfony-project.com/trac/wiki/SymfonyPlugins](http://www.symfony-project.com/trac/wiki/SymfonyPlugins)).952 5. Add the new plug-in wiki page (`[wiki:sfSamplePlugin]`) to the list of available plug-ins, which is also a wiki page ([http://trac.symfony-project.com/wiki/SymfonyPlugins](http://trac.symfony-project.com/wiki/SymfonyPlugins)). 953 953 954 954 If you follow this procedure, users will be able to install your plug-in by simply typing the following command in a project directory: doc/branches/1.0/book/18-Performance.txt
r4666 r6118 4 4 If you expect your website will attract a crowd, performance and optimization issues should be a major factor during the development phase. Rest assured, performance has always been a chief concern among the core symfony developers. 5 5 6 While the advantages gained by accelerating the development process result in some overhead, the core symfony developers have always been cognizant of performance requirements. Accordingly, every class and every method have been closely inspected and optimized to be as fast as possible. The basic overhead, which you can measure by comparing the time to display a "hello, world" message with and without symfony, is minimal. As a result, the framework is scalable and reacts well to stress tests. And as the ultimate proof, some websites with extremely high traffic (that is, websites with millions of active subscribers and a lot of server-pressuring Ajax interactions) use symfony and are very satisfied with its performance. Check the list of websites developed with symfony in the wiki ([http:// www.symfony-project.com/trac/wiki/ApplicationsDevelopedWithSymfony](http://www.symfony-project.com/trac/wiki/ApplicationsDevelopedWithSymfony)) for names.6 While the advantages gained by accelerating the development process result in some overhead, the core symfony developers have always been cognizant of performance requirements. Accordingly, every class and every method have been closely inspected and optimized to be as fast as possible. The basic overhead, which you can measure by comparing the time to display a "hello, world" message with and without symfony, is minimal. As a result, the framework is scalable and reacts well to stress tests. And as the ultimate proof, some websites with extremely high traffic (that is, websites with millions of active subscribers and a lot of server-pressuring Ajax interactions) use symfony and are very satisfied with its performance. Check the list of websites developed with symfony in the wiki ([http://trac.symfony-project.com/wiki/ApplicationsDevelopedWithSymfony](http://trac.symfony-project.com/wiki/ApplicationsDevelopedWithSymfony)) for names. 7 7 8 8 But, of course, high-traffic websites often have the means to expand the server farm and upgrade hardware as they see fit. If you don't have the resources to do this, or if you want to be sure the full power of the framework is always at your disposal, there are a few tweaks that you can use to further speed up your symfony application. This chapter lists some of the recommended performance optimizations at all levels of the framework and they are mostly for advanced users. Some of them were already mentioned throughout the previous chapters, but you will find it useful to have them all in one place. … … 69 69 $articles = ArticlePeer::doSelect($c); 70 70 71 This can be automated by the use of a pager. The `sfPropelPager` object automatically handles the offset and the limit of a Propel query to hydrate only the objects required for a given page. Refer to the [pager documentation](http://www.symfony-project. com/cookbook/trunk/pager) for more information on this class.71 This can be automated by the use of a pager. The `sfPropelPager` object automatically handles the offset and the limit of a Propel query to hydrate only the objects required for a given page. Refer to the [pager documentation](http://www.symfony-project.org/cookbook/trunk/pager) for more information on this class. 72 72 73 73 ### Minimizing the Number of Queries with Joins … … 575 575 Some features are useful only in development, so you should not activate them in production. This is already the case by default, since the production environment in symfony is really optimized for performance. Among the performance-impacting development features, the `SF_DEBUG` mode is the most severe. As for the symfony logs, the feature is also turned off in production by default. 576 576 577 You may wonder how to get information about failed requests in production if logging is disabled, and argue that problems arise not only in development. Fortunately, symfony can use the `sfErrorLoggerPlugin` plug-in, which runs in the background in production and logs the details of 404 and 500 errors in a database. It is much faster than the file logging feature, because the plug-in methods are called only when a request fails, while the logging mechanism, once turned on, adds a nonnegligible overhead whatever the level. Check the installation instructions and manual at [http://www.symfony-project.com/ trac/wiki/sfErrorLoggerPlugin](http://www.symfony-project.com/trac/wiki/sfErrorLoggerPlugin).577 You may wonder how to get information about failed requests in production if logging is disabled, and argue that problems arise not only in development. Fortunately, symfony can use the `sfErrorLoggerPlugin` plug-in, which runs in the background in production and logs the details of 404 and 500 errors in a database. It is much faster than the file logging feature, because the plug-in methods are called only when a request fails, while the logging mechanism, once turned on, adds a nonnegligible overhead whatever the level. Check the installation instructions and manual at [http://www.symfony-project.com/wiki/sfErrorLoggerPlugin](http://trac.symfony-project.com/wiki/sfErrorLoggerPlugin). 578 578 579 579 >**TIP** … … 622 622 And that's not all, because an evident test like the preceding one also gets optimized to an empty string. 623 623 624 To apply the optimizations, you must first install the plug-in from [http:// www.symfony-project.com/trac/wiki/sfOptimizerPlugin](http://www.symfony-project.com/trac/wiki/sfOptimizerPlugin) and then call the `optimize` task, specifying an application and an environment:624 To apply the optimizations, you must first install the plug-in from [http://trac.symfony-project.com/wiki/sfOptimizerPlugin](http://trac.symfony-project.com/wiki/sfOptimizerPlugin) and then call the `optimize` task, specifying an application and an environment: 625 625 626 626 > symfony optimize myapp prod