12.07.2015 Views

A Gentle Introduction to symfony (pdf) - Bad Request

A Gentle Introduction to symfony (pdf) - Bad Request

A Gentle Introduction to symfony (pdf) - Bad Request

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 3: Running Symfony 42Listing3-18$ php <strong>symfony</strong> configure:database "mysql:host=localhost;dbname=dbname" rootmYsEcretThe configure:database task takes three arguments: the PDO DSN 25 , the username, andthe password <strong>to</strong> access the database. If you don’t need a password <strong>to</strong> access your database onthe development server, just omit the third argument.If you want <strong>to</strong> use Propel instead of Doctrine, add --orm=Propel when creating theproject with the generate:project task. And if you don’t want <strong>to</strong> use an ORM, just pass--orm=none.Application CreationNow, create the frontend application by running the generate:app task:Listing3-19$ php <strong>symfony</strong> generate:app frontendBecause the <strong>symfony</strong> shortcut file is executable, Unix users can replace all occurrences of‘php <strong>symfony</strong>’ by ‘./<strong>symfony</strong>’ from now on.On Windows you can copy the ‘<strong>symfony</strong>.bat’ file <strong>to</strong> your project and use ‘<strong>symfony</strong>’instead of ‘php <strong>symfony</strong>’:Listing3-20c:\> copy lib\vendor\<strong>symfony</strong>\data\bin\<strong>symfony</strong>.bat .Based on the application name given as an argument, the generate:app task creates thedefault direc<strong>to</strong>ry structure needed for the application under the apps/frontend/ direc<strong>to</strong>ry.SecurityBy default, the generate:app task has secured our application from the two mostwidespread vulnerabilities found on the web. That’s right, <strong>symfony</strong> au<strong>to</strong>matically takessecurity measures on our behalf.To prevent XSS attacks, output escaping has been enabled; and <strong>to</strong> prevent CSRF attacks, arandom CSRF secret has been generated.Of course, you can tweak these settings thanks <strong>to</strong> the following options:• --escaping-strategy: Enables or disables output escaping• --csrf-secret: Enables session <strong>to</strong>kens in formsIf you know nothing about XSS 26 or CSRF 27 , take the time <strong>to</strong> learn more about thesesecurity vulnerabilities.Direc<strong>to</strong>ry Structure RightsBefore trying <strong>to</strong> access your newly created project, you need <strong>to</strong> set the write permissions onthe cache/ and log/ direc<strong>to</strong>ries <strong>to</strong> the appropriate levels, so that both your web server andcommand line user can write <strong>to</strong> them:25. http://www.php.net/manual/en/pdo.drivers.php26. http://en.wikipedia.org/wiki/Cross-site_scripting27. http://en.wikipedia.org/wiki/CSRF----------------- Brought <strong>to</strong> you by

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!