Ticket #3276: docfixes.patch
| File docfixes.patch, 50.5 kB (added by tonypiper, 9 months ago) |
|---|
-
doc/03-Running-Symfony.txt
old new 27 27 28 28 Test your installation by executing the symfony CLI. Go to the new `sf_sandbox/` directory and type the following on a *nix system: 29 29 30 > ./symfony -V30 > php ./symfony -V 31 31 32 32 On Windows, issue this command: 33 33 34 > symfony -V34 > php symfony -V 35 35 36 36 You should see the sandbox version number: 37 37 … … 101 101 102 102 That's it. The symfony files and CLI are installed. Check that the installation succeeded by calling the new `symfony` command line, asking for the version number: 103 103 104 > symfony -V104 > php symfony -V 105 105 106 106 symfony version 1.1.0 (/path/to/the/pear/symfony/lib/dir) 107 107 … … 159 159 160 160 > mkdir ~/myproject 161 161 > cd ~/myproject 162 > symfony generate:project myproject162 > php symfony generate:project myproject 163 163 164 164 For an SVN installation, create a project with these commands: 165 165 … … 184 184 web/ 185 185 186 186 >**TIP** 187 >@francoisz: do we still need this tip? 187 188 >The `generate:project` task adds a `symfony` script in the project root directory. This PHP script does the same as the `symfony` command installed by PEAR, so you can call `php symfony` instead of `symfony` if you don't have native command-line support (for SVN installations). 188 189 189 190 ### Creating the Application … … 190 191 191 192 The project is not yet ready to be viewed, because it requires at least one application. To initialize it, use the `symfony generate:app` command and pass the name of the application as an argument: 192 193 193 > symfony generate:app frontend194 > php symfony generate:app frontend 194 195 195 196 This will create a `frontend/` directory in the `apps/` folder of the project root, with a default application configuration and a set of directories ready to host the file of your website: 196 197 -
doc/04-The-Basics-of-Page-Creation.txt
old new 13 13 The symfony command line automates the creation of modules. You just need to call the `init-module` task with the application name and the module name as arguments. In the previous chapter, you created a `frontend` application. To add a `content` module to this application, type the following commands: 14 14 15 15 > cd ~/myproject 16 > symfony generate:module frontend content16 > php symfony generate:module frontend content 17 17 18 18 >> dir+ ~/myproject/apps/frontend/modules/content/actions 19 19 >> file+ ~/myproject/apps/frontend/modules/content/actions/actions.class.php -
doc/05-Configuring-Symfony.txt
old new 459 459 460 460 This presents a major advantage over many PHP frameworks, where configuration files are compiled at every request, even in production. Unlike Java, PHP doesn't share an execution context between requests. For other PHP frameworks, keeping the flexibility of XML configuration files requires a major performance hit to process all the configuration at every request. This is not the case in symfony. Thanks to the cache system, the overhead caused by configuration is very low. 461 461 462 There is an important consequence of this mechanism. If you change the configuration in the production environment, you need to force the reparsing of all the configuration files for your modification to be taken into account. For that, you just need to clear the cache, either by deleting the content of the cache/ directory or, more easily, by calling the clear-cache symfonytask:462 There is an important consequence of this mechanism. If you change the configuration in the production environment, you need to force the reparsing of all the configuration files for your modification to be taken into account. For that, you just need to clear the cache, either by deleting the content of the cache/ directory or, more easily, by calling the `cache:clear` task: 463 463 464 > symfony clear-cache464 > php symfony cache:clear 465 465 466 466 Accessing the Configuration from Code 467 467 ------------------------------------- -
doc/06-Inside-the-Controller-Layer.txt
old new 61 61 62 62 One front controller exists per environment. As a matter of fact, it is the very existence of a front controller that defines an environment. The environment is defined in the `SF_ENVIRONMENT` constant. 63 63 64 To change the environment in which you're browsing your application, just choose another front controller. The default front controllers available when you create a new application with the ` symfony init-app` task are `index.php` for the production environment and `frontend_dev.php` for the development environment (provided that your application is called `frontend`). The default `mod_rewrite` configuration will use `index.php` when the URL doesn't contain a front controller script name. So both of these URLs display the same page (`mymodule/index`) in the production environment:64 To change the environment in which you're browsing your application, just choose another front controller. The default front controllers available when you create a new application with the `php symfony generate:app` task are `index.php` for the production environment and `frontend_dev.php` for the development environment (provided that your application is called `frontend`). The default `mod_rewrite` configuration will use `index.php` when the URL doesn't contain a front controller script name. So both of these URLs display the same page (`mymodule/index`) in the production environment: 65 65 66 66 http://localhost/index.php/mymodule/index 67 67 http://localhost/mymodule/index … … 89 89 90 90 ### Batch Files 91 91 92 @francoisz: is this still valid? 92 93 You may want to execute a script from the command line (or via a cron table) with access to all the symfony classes and features, for instance to launch batch e-mail jobs or to periodically update your model through a process-intensive calculation. For such a script, you need to include the same lines as in a front controller at the beginning. Listing 6-3 shows an example of the beginning of a batch script. 93 94 94 95 Listing 6-3 - Sample Batch Script … … 107 108 108 109 You can see that the only missing line is the call to the `dispatch()` method of the sfController object, which can be used only with a web server, not in a batch process. Defining an application and an environment gives you access to a specific configuration. Including the application `config.php` initiates the context and the autoloading. 109 110 110 >**TIP**111 >The symfony CLI offers an `init-batch` task, which automatically creates a skeleton similar to the one in Listing 6-3 in the `batch/` directory. Just pass it an application name, an environment name, and a batch name as arguments.112 113 111 Actions 114 112 ------- 115 113 -
doc/08-Inside-the-Model-Layer.txt
old new 110 110 111 111 The schema is used to build the model classes of the ORM layer. To save execution time, these classes are generated with a command-line task called `propel-build-model`. 112 112 113 > symfony propel-build-model113 > php symfony propel:build-model 114 114 115 115 >**TIP** 116 >After building your model, you must remember to clear symfony's internal cache with ` symfony cc` so symfony can find your newly created models.116 >After building your model, you must remember to clear symfony's internal cache with `php symfony cc` so symfony can find your newly created models. 117 117 118 118 Typing this command will launch the analysis of the schema and the generation of base data model classes in the `lib/model/om/` directory of your project: 119 119 … … 920 920 921 921 If you start your application by writing the `schema.yml` file, symfony can generate a SQL query that creates the tables directly from the YAML data model. To use the query, go to your root project directory and type this: 922 922 923 > symfony propel-build-sql923 > php symfony propel:build-sql 924 924 925 925 A `lib.model.schema.sql` file will be created in `myproject/data/sql/`. Note that the generated SQL code will be optimized for the database system defined in the `phptype` parameter of the `propel.ini` file. 926 926 … … 929 929 > mysqladmin -u root -p create blog 930 930 > mysql -u root -p blog < data/sql/lib.model.schema.sql 931 931 932 The generated SQL is also helpful to rebuild the database in another environment, or to change to another DBMS. If the connection settings are properly defined in your `propel.ini`, you can even use the ` symfony propel-insert-sql` command to do this automatically.932 The generated SQL is also helpful to rebuild the database in another environment, or to change to another DBMS. If the connection settings are properly defined in your `propel.ini`, you can even use the `php symfony propel:insert-sql` command to do this automatically. 933 933 934 934 >**TIP** 935 935 >The command line also offers a task to populate your database with data based on a text file. See Chapter 16 for more information about the `propel:data-load` task and the YAML fixture files. … … 940 940 941 941 In order to do this, you need to make sure that the project `propel.ini` file points to the correct database and contains all connection settings, and then call the `propel-build-schema` command: 942 942 943 > symfony propel-build-schema943 > php symfony propel:build-schema 944 944 945 945 A brand-new `schema.yml` file built from your database structure is generated in the `config/` directory. You can build your model based on this schema. 946 946 … … 946 946 947 947 The schema-generation command is quite powerful and can add a lot of database-dependent information to your schema. As the YAML format doesn't handle this kind of vendor information, you need to generate an XML schema to take advantage of it. You can do this simply by adding an `xml` argument to the `build-schema` task: 948 948 949 > symfony propel-build-schema xml949 > php symfony propel:build-schema xml 950 950 951 951 Instead of generating a `schema.yml` file, this will create a `schema.xml` file fully compatible with Propel, containing all the vendor information. But be aware that generated XML schemas tend to be quite verbose and difficult to read. 952 952 -
doc/12-Caching.txt
old new 281 281 282 282 ### Clearing the Entire Cache 283 283 284 The `c lear-cache` task of the symfony command line erases the cache (HTML, configuration, and i18n cache). You can pass it arguments to erase only a subset of the cache, as shown in Listing 12-8. Remember to call it only from the root of a symfony project.284 The `cache:clear` task of the symfony command line erases the cache (HTML, configuration, and i18n cache). You can pass it arguments to erase only a subset of the cache, as shown in Listing 12-8. Remember to call it only from the root of a symfony project. 285 285 286 286 Listing 12-8 - Clearing the Cache 287 287 … … 286 286 Listing 12-8 - Clearing the Cache 287 287 288 288 // Erase the whole cache 289 > symfony clear-cache289 > php symfony cache:clear 290 290 291 291 // Short syntax 292 > symfony cc292 > php symfony cc 293 293 294 294 // Erase only the cache of the frontend application 295 > symfony clear-cachefrontend295 > php symfony cache:clear frontend 296 296 297 297 // Erase only the HTML cache of the frontend application 298 > symfony clear-cachefrontend template298 > php symfony cache:clear frontend template 299 299 300 300 // Erase only the configuration cache of the frontend application 301 > symfony clear-cachefrontend config301 > php symfony cache:clear frontend config 302 302 303 303 ### Clearing Selective Parts of the Cache 304 304 … … 472 472 473 473 http://myapp.example.com/frontend_staging.php/user/list 474 474 475 >**TIP**476 >Instead of copying an existing one, you can create a new front controller with the `symfony` command line. For instance, to create a `staging` environment for the `frontend` application, called `frontend_staging.php` and where `SF_DEBUG` is `true`, just call `symfony init-controller frontend staging frontend_staging true`.477 478 475 ### Monitoring Performance 479 476 480 477 Chapter 16 will explore the web debug toolbar and its contents. However, as this toolbar offers valuable information about cached elements, here is a brief description of its cache features. -
doc/13-I18n-and-L10n.txt
old new 215 215 216 216 ### Using the Generated I18n Objects 217 217 218 Once the corresponding object model is built (don't forget to call ` symfony` `propel-build-model` and clear the cache with a `symfony cc` after each modification of the `schema.yml`), you can use your `Product` class with i18n support as if there were only one table, as shown in Listing 13-8.218 Once the corresponding object model is built (don't forget to call `php symfony propel:build-model` and clear the cache with a `php symfony cc` after each modification of the `schema.yml`), you can use your `Product` class with i18n support as if there were only one table, as shown in Listing 13-8. 219 219 220 220 Listing 13-8 - Dealing with i18n Objects 221 221 -
doc/14-Generators.txt
old new 19 19 20 20 All the code generation tasks based on the model create an entire module, and result from a single call to the symfony command line in the shape of the following: 21 21 22 > symfony <TASK_NAME> <APP_NAME> <MODULE_NAME> <CLASS_NAME>22 > php symfony <TASK_NAME> <APP_NAME> <MODULE_NAME> <CLASS_NAME> 23 23 24 The code generation tasks are `propel-init-crud`, `propel-generate-crud`, and `propel-init-admin`. 24 @francoisz: propel-init-crud is now merged with propel:generate-crud... so this section needs fixing 25 The code generation tasks are `propel-init-crud`, `propel:generate-crud`, and `propel:init-admin`. 25 26 26 27 ### Scaffolding and Administration 27 28 … … 36 37 37 38 Symfony offers two ways to generate code: either by inheritance (`init`) or by code generation (`generate`). 38 39 39 You can initiate a module, that is, create empty classes that inherit from the framework. This masks the PHP code of the actions and the templates to avoid them from being modified. This is useful if your data structure is not final, or if you just need a quick interface to a database to manipulate records. The code executed at runtime is not located in your application, but in the cache. The command-line tasks for this kind of generation start with `propel -init-`.40 You can initiate a module, that is, create empty classes that inherit from the framework. This masks the PHP code of the actions and the templates to avoid them from being modified. This is useful if your data structure is not final, or if you just need a quick interface to a database to manipulate records. The code executed at runtime is not located in your application, but in the cache. The command-line tasks for this kind of generation start with `propel:init-`. 40 41 41 42 Initiated action code is empty. For instance, an initiated `article` module has actions looking like this: 42 43 … … 45 46 { 46 47 } 47 48 48 On the other hand, you can also generate the code of the actions and the templates so that it can be modified. The resulting module is therefore independent from the classes of the framework, and cannot be altered using configuration files. The command-line tasks for this kind of generation start with `propel -generate-`.49 On the other hand, you can also generate the code of the actions and the templates so that it can be modified. The resulting module is therefore independent from the classes of the framework, and cannot be altered using configuration files. The command-line tasks for this kind of generation start with `propel:generate-`. 49 50 50 51 As the scaffoldings are built to serve as a base for further developments, it is often best to generate a scaffolding. On the other hand, an administration should be easy to update through a change in the configuration, and it should remain usable even if the data model changes. That's why administrations are initiated only. 51 52 … … 88 89 89 90 To generate the scaffolding for an `article` module based on the `Article` model class, type the following: 90 91 91 > symfony propel-generate-crud frontend article Article92 > php symfony propel:generate-crud frontend article Article 92 93 93 94 Symfony reads the definition of the `Article` class in the `schema.yml` and creates a set of templates and actions based on it, in the `frontend/modules/article/` directory. 94 95 … … 160 161 161 162 To initiate a Propel scaffolding that will create an `article` module to deal with the records of the `Article` model class name, type the following: 162 163 163 > symfony propel-init-crud frontend article Article 164 @francoisz: propel-init-crud is now merged with propel:generate-crud... so this section needs fixing 165 > php symfony propel-init-crud frontend article Article 164 166 165 167 You can then access the `list` view using the default action: 166 168 … … 175 177 Administration 176 178 -------------- 177 179 178 Symfony can generate more advanced modules, still based on model class definitions from the `schema.yml` file, for the back-end of your applications. You can create an entire site administration with only generated administration modules. The examples of this section will describe administration modules added to a `backend` application. If your project doesn't have a `backend` application, create its skeleton now by calling the ` init-app` task:180 Symfony can generate more advanced modules, still based on model class definitions from the `schema.yml` file, for the back-end of your applications. You can create an entire site administration with only generated administration modules. The examples of this section will describe administration modules added to a `backend` application. If your project doesn't have a `backend` application, create its skeleton now by calling the `generate:app` task: 179 181 180 > symfony init-app backend182 > php symfony generate:app backend 181 183 182 184 Administration modules interpret the model by way of a special configuration file called `generator.yml`, which can be altered to extend all the generated components and the module look and feel. Such modules benefit from the usual module mechanisms described in previous chapters (layout, validation, routing, custom configuration, autoloading, and so on). You can also override the generated action or templates, in order to integrate your own features into the generated administration, but `generator.yml` should take care of the most common requirements and restrict the use of PHP code only to the very specific. 183 185 … … 183 185 184 186 ### Initiating an Administration Module 185 187 186 With symfony, you build an administration on a per-module basis. A module is generated based on a Propel object using the `propel -init-admin` task, which uses syntax similar to that used to initiate a scaffolding:188 With symfony, you build an administration on a per-module basis. A module is generated based on a Propel object using the `propel:init-admin` task, which uses syntax similar to that used to initiate a scaffolding: 187 189 188 > symfony propel-init-admin backend article Article190 > php symfony propel:init-admin backend article Article 189 191 190 192 This call is enough to create an `article` module in the `backend` application based on the `Article` class definition, and is accessible by the following: 191 193 … … 300 302 301 303 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 304 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:305 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: 304 306 305 > symfony propel-init-admin backend comment Comment307 > php symfony propel:init-admin backend comment Comment 306 308 307 309 Figure 14-7 - The administration generator cheat sheet 308 310 -
doc/15-Unit-and-Functional-Testing.txt
old new 107 107 108 108 Listing 15-2 - Launching a Single Unit Test from the Command Line 109 109 110 > symfony test-unit strtolower110 > php symfony test:unit strtolower 111 111 112 112 1..7 113 113 # strtolower() … … 224 224 225 225 Listing 15-4 - The Count of Test Run Helps You to Plan Tests 226 226 227 > symfony test-unit example227 > php symfony test:unit example 228 228 229 229 1..16 230 230 # hello world … … 268 268 foo/ 269 269 barTest.php 270 270 271 > symfony test-unit myFunction ## Run myFunctionTest.php272 > symfony test-unit myFunction mySecondFunction ## Run both tests273 > symfony test-unit 'foo/*' ## Run barTest.php274 > symfony test-unit '*' ## Run all tests (recursive)271 > php symfony test:unit myFunction ## Run myFunctionTest.php 272 > php symfony test:unit myFunction mySecondFunction ## Run both tests 273 > php symfony test:unit 'foo/*' ## Run barTest.php 274 > php symfony test:unit '*' ## Run all tests (recursive) 275 275 276 276 ### Stubs, Fixtures, and Autoloading 277 277 … … 403 403 404 404 A functional test traditionally starts with an initialization of a test browser object. This object makes a request to an action and verifies that some elements are present in the response. 405 405 406 @francoisz: propel-init-crud is now merged with propel:generate-crud... so this section needs fixing 406 407 For example, every time you generate a module skeleton with the `init-module` or the `propel-init-crud` tasks, symfony creates a simple functional test for this module. The test makes a request to the default action of the module and checks the response status code, the module and action calculated by the routing system, and the presence of a certain sentence in the response content. For a `foobar` module, the generated `foobarActionsTest.php` file looks like Listing 15-9. 407 408 408 409 Listing 15-9 - Default Functional Test for a New Module, in `tests/functional/frontend/foobarActionsTest.php` … … 428 429 429 430 A functional test can contain several requests and more complex assertions; you will soon discover all the possibilities in the upcoming sections. 430 431 431 To launch a functional test, use the `test -functional` task with the symfony command line, as shown in Listing 15-10. This task expects an application name and a test name (omit the `Test.php` suffix).432 To launch a functional test, use the `test:functional` task with the symfony command line, as shown in Listing 15-10. This task expects an application name and a test name (omit the `Test.php` suffix). 432 433 433 434 Listing 15-10 - Launching a Single Functional Test from the Command Line 434 435 435 > symfony test-functional frontend foobarActions436 > php symfony test:functional frontend foobarActions 436 437 437 438 # get /comment/index 438 439 ok 1 - status code is 200 … … 737 738 [php] 738 739 $b = new sfTestBrowser('myapp.example.com', '123.456.789.123'); 739 740 740 ### The test -functional Task741 ### The test:functional Task 741 742 742 The `test -functional` task can run one or more functional tests, depending on the number of arguments received. The rules look much like the ones of the `test-unit` task, except that the functional test task always expects an application as first argument, as shown in Listing 15-27.743 The `test:functional` task can run one or more functional tests, depending on the number of arguments received. The rules look much like the ones of the `test-unit` task, except that the functional test task always expects an application as first argument, as shown in Listing 15-27. 743 744 744 745 Listing 15-27 - Functional Test Task Syntax 745 746 … … 753 754 myOtherScenarioTest.php 754 755 755 756 ## Run all functional tests for one application, recursively 756 > symfony test-functional frontend757 > php symfony test:functional frontend 757 758 758 759 ## Run one given functional test 759 > symfony test-functional frontend myScenario760 > php symfony test:functional frontend myScenario 760 761 761 762 ## Run several tests based on a pattern 762 > symfony test-functional frontend my*763 > php symfony test:functional frontend my* 763 764 764 765 Test Naming Practices 765 766 --------------------- … … 825 826 826 827 ### Executing Tests in a Test Harness 827 828 828 The `test -unit` and `test-functional` tasks can launch a single test or a set of tests. But if you call these tasks without any parameter, they launch all the unit and functional tests written in the `test/` directory. A particular mechanism is involved to isolate each test file in an independent sandbox, to avoid contamination risks between tests. Furthermore, as it wouldn't make sense to keep the same output as with single test files in that case (the output would be thousands of lines long), the tests results are compacted into a synthetic view. That's why the execution of a large number of test files uses a test harness, that is, an automated test framework with special abilities. A test harness relies on a component of the lime framework called `lime_harness`. It shows a test status file by file, and an overview at the end of the number of tests passed over the total, as you see in Listing 15-31.829 The `test:unit` and `test:functional` tasks can launch a single test or a set of tests. But if you call these tasks without any parameter, they launch all the unit and functional tests written in the `test/` directory. A particular mechanism is involved to isolate each test file in an independent sandbox, to avoid contamination risks between tests. Furthermore, as it wouldn't make sense to keep the same output as with single test files in that case (the output would be thousands of lines long), the tests results are compacted into a synthetic view. That's why the execution of a large number of test files uses a test harness, that is, an automated test framework with special abilities. A test harness relies on a component of the lime framework called `lime_harness`. It shows a test status file by file, and an overview at the end of the number of tests passed over the total, as you see in Listing 15-31. 829 830 830 831 Listing 15-31 - Launching All Tests in a Test Harness 831 832 832 > symfony test-unit833 > php symfony test:unit 833 834 834 835 unit/myFunctionTest.php................ok 835 836 unit/mySecondFunctionTest.php..........ok … … 842 843 843 844 The tests are executed the same way as when you call them one by one, only the output is made shorter to be really useful. In particular, the final chart focuses on the failed tests and helps you locate them. 844 845 845 You can launch all the tests with one call using the `test -all` task, which also uses a test harness, as shown in Listing 15-32. This is something that you should do before every transfer to production, to ensure that no regression has appeared since the latest release.846 You can launch all the tests with one call using the `test:all` task, which also uses a test harness, as shown in Listing 15-32. This is something that you should do before every transfer to production, to ensure that no regression has appeared since the latest release. 846 847 847 848 Listing 15-32 - Launching All the Tests of a Project 848 849 849 > symfony test-all850 > php symfony test:all 850 851 851 852 ### Accessing a Database 852 853 … … 861 862 // Optionally, you can retrieve the current database connection 862 863 $con = Propel::getConnection(); 863 864 864 You should populate the database with fixtures before starting the tests. This can be done via the `sfPropelData` object. This object can load data from a file, just like the `propel -load-data` task, or from an array, as shown in Listing 15-34.865 You should populate the database with fixtures before starting the tests. This can be done via the `sfPropelData` object. This object can load data from a file, just like the `propel:data-load` task, or from an array, as shown in Listing 15-34. 865 866 866 867 Listing 15-34 - Populating a Database from a Test File 867 868 … … 977 978 Summary 978 979 ------- 979 980 980 Automated tests include unit tests to validate methods or functions and functional tests to validate features. Symfony relies on the lime testing framework for unit tests and provides an `sfTestBrowser` class especially for functional tests. They both provide many assertion methods, from basic to the most advanced, like CSS selectors. Use the symfony command line to launch tests, either one by one (with the `test -unit` and `test-functional` tasks) or in a test harness (with the `test-all` task). When dealing with data, automated tests use fixtures and stubs, and this is easily achieved within symfony unit tests.981 Automated tests include unit tests to validate methods or functions and functional tests to validate features. Symfony relies on the lime testing framework for unit tests and provides an `sfTestBrowser` class especially for functional tests. They both provide many assertion methods, from basic to the most advanced, like CSS selectors. Use the symfony command line to launch tests, either one by one (with the `test:unit` and `test:functional` tasks) or in a test harness (with the `test:all` task). When dealing with data, automated tests use fixtures and stubs, and this is easily achieved within symfony unit tests. 981 982 982 983 If you make sure to write enough unit tests to cover a large part of your applications (maybe using the TDD methodology), you will feel safer when refactoring internals or adding new features, and you may even gain some time on the documentation task. -
doc/16-Application-Management-Tools.txt
old new 126 126 127 127 Don't forget to periodically purge the `log/` directory of your applications, because these files have the strange habit of growing by several megabytes in a few days, depending, of course, on your traffic. Symfony provides a special `log-purge` task for this purpose, which you can launch regularly by hand or put in a cron table. For example, the following command erases the symfony log files: 128 128 129 > symfony log-purge129 > php symfony log:clear 130 130 131 131 For both better performance and security, you probably want to store symfony logs in several small files instead of one single large file. The ideal storage strategy for log files is to back up and empty the main log file regularly, but to keep only a limited number of backups. You can enable such a log rotation with a `period` of `7` days and a `history` (number of backups) of `10`, as shown in Listing 16-6. You would work with one active log file plus ten backup files containing seven days' worth of history each. Whenever the next period of seven days ends, the current active log file goes into backup, and the oldest backup is erased. 132 132 … … 132 132 133 133 Listing 16-6 - Launching Log Rotation 134 134 135 > symfony --period=7 --history=10 log-rotate frontend prod135 > php symfony --period=7 --history=10 log:rotate frontend prod 136 136 137 137 The backup log files are stored in the `logs/history/` directory and suffixed with the date they were saved. 138 138 … … 370 370 371 371 ### Launching the Import 372 372 373 The `propel -load-data` task imports data from YAML files to a database. The connection settings come from the `databases.yml` file, and therefore need an application name to run. Optionally, you can specify an environment name by adding a `--env` option (`dev` by default).373 The `propel:data-load` task imports data from YAML files to a database. The connection settings come from the `databases.yml` file, and therefore need an application name to run. Optionally, you can specify an environment name by adding a `--env` option (`dev` by default). 374 374 375 > symfony propel:data-load --env=prod frontend375 > php symfony propel:data-load --env=prod frontend 376 376 377 377 This command reads all the YAML fixture files from the `data/fixtures/` directory and inserts the records into the database. By default, it replaces the existing database content, but if you add an `--append` option, the command will not erase the current data. 378 378 379 > symfony propel:data-load --append frontend379 > php symfony propel:data-load --append frontend 380 380 381 381 You can specify another fixture directory in the call. In this case, add a path relative to the project directory. 382 382 383 > symfony propel:data-load frontend --dir[]=data/myfixtures383 > php symfony propel:data-load frontend --dir[]=data/myfixtures 384 384 385 385 ### Using Linked Tables 386 386 … … 434 434 435 435 That's why symfony provides a utility to "freeze" a project--to copy all the necessary symfony libraries into the project `data/`, `lib/`, and `web/` directories. The project then becomes a kind of sandbox, an independent, stand-alone application. 436 436 437 > symfonyfreeze437 > php symfony project:freeze 438 438 439 439 Once a project is frozen, you can transfer the project directory into production, and it will work without any need for PEAR, symbolic links, or whatever else. 440 440 … … 441 441 >**TIP** 442 442 >Various frozen projects can work on the same server with different versions of symfony without any problems. 443 443 444 To revert a project to its initial state, use the ` unfreeze` task. It erases the `data/symfony/`, `lib/symfony/`, and `web/sf/` directories.444 To revert a project to its initial state, use the `project:unfreeze` task. It erases the `data/symfony/`, `lib/symfony/`, and `web/sf/` directories. 445 445 446 > symfonyunfreeze446 > php symfony project:unfreeze 447 447 448 448 Note that if you had symbolic links to a symfony installation prior to the freeze, symfony will remember them and re-create the symbolic links in the original location. 449 449 … … 473 473 474 474 Doing an rsync over SSH requires several commands, and synchronization can occur a lot of times in the life of an application. Fortunately, symfony automates this process with just one command: 475 475 476 > symfony syncproduction476 > php symfony project:deploy production 477 477 478 478 This command launches the rsync command in dry mode; that is, it shows which files must be synchronized but doesn't actually synchronize them. If you want the synchronization to be done, you need to request it explicitly by adding `go`. 479 479 480 > symfony syncproduction go480 > php symfony project:deploy production go 481 481 482 482 Don't forget to clear the cache in the production server after synchronization. 483 483 … … 526 526 527 527 ### Managing a Production Application 528 528 529 The command that is used most often in production servers is `c lear-cache`. You must run it every time you upgrade symfony or your project (for instance, after calling the `sync` task), and every time you change the configuration in production.529 The command that is used most often in production servers is `cache:clear`. You must run it every time you upgrade symfony or your project (for instance, after calling the `project:deploy` task), and every time you change the configuration in production. 530 530 531 > symfony clear-cache531 > php symfony cache:clear 532 532 533 533 >**TIP** 534 534 >If the command-line interface is not available in your production server, you can still clear the cache manually by erasing the contents of the `cache/` folder. … … 535 535 536 536 You can temporarily disable your application--for instance, when you need to upgrade a library or a large amount of data. 537 537 538 > symfonydisable APPLICATION_NAME ENVIRONMENT_NAME538 > php symfony project:disable APPLICATION_NAME ENVIRONMENT_NAME 539 539 540 540 By default, a disabled application displays the `$sf_symfony_data_dir/web/errors/unavailable.php` page, but if you create your own `unavailable.php` file in your project's `web/errors/` directory, symfony will use it instead. 541 541 542 The ` enable` task reenables the application and clears the cache.542 The `project:enable` task reenables the application and clears the cache. 543 543 544 > symfonyenable APPLICATION_NAME ENVIRONMENT_NAME544 > php symfony project:enable APPLICATION_NAME ENVIRONMENT_NAME 545 545 546 546 >**SIDEBAR** 547 547 >Displaying an unavailable page when clearing the cache … … 548 548 > 549 549 >If you set the `check_lock` parameter to `on` in the `settings.yml` file, symfony will lock the application when the cache is being cleared, and all the requests arriving before the cache is finally cleared are then redirected to a page saying that the application is temporarily unavailable. If the cache is large, the delay to clear it may be longer than a few milliseconds, and if your site's traffic is high, this is a recommended setting. This unavailable page is the same as the one displayed when you call the symfony `disable` task. The `check_lock` parameter is deactivated by default because it has a very slight negative impact on performance. 550 550 > 551 >The ` clear-controllers` task clears the `web/` directory of all controllers other than the ones running in a production environment. If you do not include the development front controllers in the `rsync_exclude.txt` file, this command guarantees that a backdoor will not reveal the internals of your application.551 >The `project:clear-controllers` task clears the `web/` directory of all controllers other than the ones running in a production environment. If you do not include the development front controllers in the `rsync_exclude.txt` file, this command guarantees that a backdoor will not reveal the internals of your application. 552 552 > 553 > > symfonyclear-controllers553 > > php symfony project:clear-controllers 554 554 > 555 >The permissions of the project files and directories can be broken if you use a checkout from an SVN repository. The ` fix-perms` task fixes directory permissions, to change the `log/` and `cache/` permissions to 0777, for example (these directories need to be writable for the framework to work correctly).555 >The permissions of the project files and directories can be broken if you use a checkout from an SVN repository. The `project:permissions` task fixes directory permissions, to change the `log/` and `cache/` permissions to 0777, for example (these directories need to be writable for the framework to work correctly). 556 556 > 557 > > symfony fix-perms557 > > php symfony project:permissions 558 558 559 559 >**SIDEBAR** 560 >@francoisz: Do we need this sidebar now tonypiper, 2008-04-04? 560 561 >Access to the symfony commands in production 561 562 > 562 563 >If your production server has a PEAR installation of symfony, then the symfony command line is available from every directory and will work just as it does in development. For frozen projects, however, you need to add `php` before the `symfony` command to be able to launch tasks: … … 563 564 > 564 565 > 565 566 > // With symfony installed via PEAR 566 > > symfony [options] <TASK> [parameters]567 > > php symfony [options] <TASK> [parameters] 567 568 > 568 569 > // With symfony frozen in the project or symlinked 569 570 > > php symfony [options] <TASK> [parameters] -
doc/17-Extending-Symfony.txt
old new 680 680 ... 681 681 682 682 * The plug-in configuration is to be included in the plug-in bootstrap script (`config.php`). This file is executed after the application and project configuration, so symfony is already bootstrapped at that time. You can use this file, for instance, to add directories to the PHP include path or to extend existing classes with mixins. 683 * Fixtures files located in the plug-in `data/fixtures/` directory are processed by the `propel -load-data` task.684 * Tasks are immediately available to the symfony command line as soon as the plug-in is installed. It is a best practice to prefix the task by something meaningful--for instance, the plug-in name. Type ` symfony` to see the list of available tasks, including the ones added by plug-ins.683 * Fixtures files located in the plug-in `data/fixtures/` directory are processed by the `propel:data-load` task. 684 * Tasks are immediately available to the symfony command line as soon as the plug-in is installed. It is a best practice to prefix the task by something meaningful--for instance, the plug-in name. Type `php symfony` to see the list of available tasks, including the ones added by plug-ins. 685 685 * Custom classes are autoloaded just like the ones you put in your project `lib/` folders. 686 686 * Helpers are automatically found when you call `use_helper()` in templates. They must be in a` helper/` subdirectory of one of the plug-in's `lib/` directory. 687 687 * Model classes in `myplugin/lib/model/` specialize the model classes generated by the Propel builder (in `myplugin/lib/model/om/` and `myplugin/lib/model/map/`). They are, of course, autoloaded. Be aware that you cannot override the generated model classes of a plug-in in your own project directories. -
doc/18-Performance.txt
old new 392 392 * When you create a new class: Adding a class to an autoloading directory (one of the project's `lib/` folders) is not enough to have symfony find it automatically. You must clear the autoloading configuration cache so that symfony browses again all the directories of the `autoload.yml` file and references the location of autoloadable classes--including the new ones. 393 393 * When you change the configuration in production: The configuration is parsed only during the first request in production. Further requests use the cached version instead. So a change in the configuration in the production environment (or any environment where `SF_DEBUG` is turned off) doesn't take effect until you clear the cached version of the file. 394 394 * When you modify a template in an environment where the template cache is enabled: The valid cached templates are always used instead of existing templates in production, so a template change is ignored until the template cache is cleared or outdated. 395 * When you update an application with the ` sync` command: This case usually covers the three previous modifications.395 * When you update an application with the `project:deploy` command: This case usually covers the three previous modifications. 396 396 397 397 The problem with clearing the whole cache is that the next request will take quite long to process, because the configuration cache needs to be regenerated. Besides, the templates that were not modified will be cleared from the cache as well, losing the benefit of previous requests. 398 398 399 That means it's a good idea to clear only the cache files that really need to be regenerated. Use the options of the `c lear-cache` task to define a subset of cache files to clear, as demonstrated in Listing 18-14.399 That means it's a good idea to clear only the cache files that really need to be regenerated. Use the options of the `cache:clear` task to define a subset of cache files to clear, as demonstrated in Listing 18-14. 400 400 401 401 Listing 18-14 - Clearing Only Selective Parts of the Cache 402 402 … … 401 401 Listing 18-14 - Clearing Only Selective Parts of the Cache 402 402 403 403 // Clear only the cache of the frontend application 404 > symfony clear-cachefrontend404 > php symfony cache:clear frontend 405 405 406 406 // Clear only the HTML cache of the frontend application 407 > symfony clear-cachefrontend template407 > php symfony cache:clear frontend template 408 408 409 409 // Clear only the configuration cache of the frontend application 410 > symfony clear-cachefrontend config410 > php symfony cache:clear frontend config 411 411 412 412 You can also remove files by hand in the `cache/` directory, or clear template cache files selectively from the action with the `$cacheManager->remove()` method, as described in Chapter 12. 413 413 … … 488 488 The `sfFunctionCache` constructor expects a cache object. The first argument of the `call()` method must be a callable, so it can be a function name, an array of a class name and static method name, or an array of an object name and public method name. As for the other argument of the `call()` method, it's an array of arguments that will be passed to the callable. 489 489 490 490 >**CAUTION** 491 >If you use a file based cache object as in the example, it's better to give a cache directory under the `cache/` directory, as it will be cleanup automatically by the `c lear-cache` task. If you store the function cache somewhere else, it will not be cleared automatically when you clear the cache through the command line.491 >If you use a file based cache object as in the example, it's better to give a cache directory under the `cache/` directory, as it will be cleanup automatically by the `cache:clear` task. If you store the function cache somewhere else, it will not be cleared automatically when you clear the cache through the command line. 492 492 493 493 ### Caching Data in the Server 494 494 … … 617 617 618 618 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: 619 619 620 > symfony optimize frontend prod620 > php symfony optimize frontend prod 621 621 622 622 If you want to apply other optimization strategies to your code, the `sfOptimizer` plug-in might be a good starting place. 623 623 -
doc/19-Mastering-Symfony-s-Configuration-Files.txt
old new 38 38 Two other pages bear a symfony look and feel, and they also need to be customized before deployment to production. These pages are not in the `default` module, because they are called when symfony cannot run properly. Instead, you will find these default pages in the `$sf_symfony_data_dir/web/errors/` directory: 39 39 40 40 * `error500.php`: Page called when an internal server error occurs in the production environment. In other environments (where `SF_DEBUG` is set to `true`), when an error occurs, symfony displays the full execution stack and an explicit error message (see Chapter 16 for details). 41 * `unavailable.php`: Page called when a user requests a page while the application is disabled (with the `disable` task). It is also called while the cache is being cleared (that is, between a call to the ` symfony clear-cache` task and the end of this task execution). On systems with a very large cache, the cache-clearing process can take several seconds. Symfony cannot execute a request with a partially cleared cache, so requests received before the end of the process are redirected to this page.41 * `unavailable.php`: Page called when a user requests a page while the application is disabled (with the `disable` task). It is also called while the cache is being cleared (that is, between a call to the `php symfony cache:clear` task and the end of this task execution). On systems with a very large cache, the cache-clearing process can take several seconds. Symfony cannot execute a request with a partially cleared cache, so requests received before the end of the process are redirected to this page. 42 42 43 43 To customize these pages, simply create `error500.php` and `unavailable.php` pages in your application's `web/errors/` directory. Symfony will use these instead of its own. 44 44 … … 62 62 `cache` | Enables template caching (see Chapter 12). Set it to `on` if one of your modules includes `cache.yml` file. The cache filter (`sfCacheFilter`) is enabled only if it is on. | `off` in development, `on` in production 63 63 `web_debug` | Enables the web debug toolbar for easy debugging (see Chapter 16). Set it to `on` to display the toolbar on every page. The web debug filter (`sfWebDebugFilter`) is enabled ony if it is on. | `on` in development, `off` in production 64 64 `check_symfony_version` | Enables the check of the symfony version for every request. Set it to on for automatic cache clearing after a framework upgrade. Leave it set to off if you always clear the cache after an upgrade. | `off` 65 `check_lock` | Enables the application lock system, triggered by the `c lear-cache` and `disable` tasks (see the previous section). Set it to `on` to have all requests to disabled applications redirected to the `$sf_symfony_data_dir/web/errors/unavailable.php` page. | `off`65 `check_lock` | Enables the application lock system, triggered by the `cache:clear` and `project:disable` tasks (see the previous section). Set it to `on` to have all requests to disabled applications redirected to the `$sf_symfony_data_dir/web/errors/unavailable.php` page. | `off` 66 66 `compressed` | Enables PHP response compression. Set it to `on` to compress the outgoing HTML via the PHP compression handler. | `off` 67 67 `use_process_cache` | Enables symfony optimizations based on PHP accelerators. When such an accelerator (for instance, APC, XCache, or eAccelerator) is installed, symfony takes advantage of its features to keep objects and configuration in memory between requests. Set the parameter to `off` in development or when you don't want PHP accelerator optimizations. Note that even if you don't have any accelerator installed, leaving it set to `on` will not harm performance. | `on` 68 68 … … 377 377 $sf_symfony_lib_dir = '/path/to/symfony/lib'; 378 378 $sf_symfony_data_dir = '/path/to/symfony/data'; 379 379 380 These paths are initialized when you call a ` symfony init-project` from the command line, and refer to the symfony installation used to build the project. They are used both by the command line and by the MVC architecture.380 These paths are initialized when you call a `php symfony generate:project` from the command line, and refer to the symfony installation used to build the project. They are used both by the command line and by the MVC architecture. 381 381 382 382 This means that you can switch to another installation of symfony by changing the paths to the framework files. 383 383