You must have composer and phing installed.
Create a new project by running the command
$ composer create-project nerdery/symfony-standard clientnameblog
This will create a new symfony project in the directory clientnameblog
.
Composer will copy the files from nerdery/symfony-standard and install all of
the dependencies and then run the install hook, which will prompt you for
settings for your parameters.yml file:
Writing lock file
Generating autoload files
Creating the "app/config/parameters.yml" file
Some parameters are missing. Please provide them.
database_driver (pdo_mysql):
database_host (127.0.0.1):
database_port (null):
database_name (symfony): clientnameblog
database_user (root):
database_password (null):
mailer_transport (smtp):
mailer_host (127.0.0.1):
mailer_user (null):
mailer_password (null):
locale (en):
secret (ThisTokenIsNotSoSecretChangeIt):
email_dev_delivery (null):
Change into the new directory
$ cd clientnameblog
Run the phing install
command to run all the tasks for installing the
application. During this process it will ask you for the application
environment. Symfony has two environments: dev
and prod
. For development,
type dev
when prompted.
$ phing install
Buildfile: /var/www/clientnameblog/build.xml
Symfony2 Build Template > clean:cache:clear:
[delete] Directory /var/www/clientnameblog/app/logs does not exist or is not a directory.
Symfony2 Build Template > build:prepare:
[echo] Creating build directories ...
[mkdir] Created dir: /var/www/clientnameblog/app/cache
[mkdir] Created dir: /var/www/clientnameblog/app/logs
[mkdir] Created dir: /var/www/clientnameblog/build
[mkdir] Created dir: /var/www/clientnameblog/build/output
[mkdir] Created dir: /var/www/clientnameblog/build/docs
[mkdir] Created dir: /var/www/clientnameblog/build/docs/phpdoc
[mkdir] Created dir: /var/www/clientnameblog/build/docs/docblox
[mkdir] Created dir: /var/www/clientnameblog/build/logs
[mkdir] Created dir: /var/www/clientnameblog/build/logs/coverage
[mkdir] Created dir: /var/www/clientnameblog/build/logs/pdepend
Symfony2 Build Template > build:configs:
[phingcall] Calling Buildfile '/var/www/clientnameblog/build.xml' with target 'build:phpunit:config'
Symfony2 Build Template > build:phpunit:config:
[copy] Copying 1 file to /var/www/clientnameblog/app
[phingcall] Calling Buildfile '/var/www/clientnameblog/build.xml' with target 'build:htaccess'
Symfony2 Build Template > build:htaccess:
[phingcall] Calling Buildfile '/var/www/clientnameblog/build.xml' with target 'build:htaccess:from-prompt'
Symfony2 Build Template > build:htaccess:from-prompt:
Application environment
[prod]? dev
[copy] Copying 1 file to /var/www/clientnameblog/web
Symfony2 Build Template > detect-composerbin:
[echo] Using composer at '/usr/local/bin/composer'
Symfony2 Build Template > build:dependencies:install:
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
Updating the "app/config/parameters.yml" file
Symfony2 Build Template > build:permissions:
[chmod] Changed file mode on '/var/www/clientnameblog/app/logs/' to 777
[chmod] Changed file mode on '/var/www/clientnameblog/app/cache/' to 777
Symfony2 Build Template > symfony:assets:install:
Installing assets using the symlink option
Installing assets for Symfony\Bundle\FrameworkBundle into web/bundles/framework
Installing assets for Sensio\Bundle\DistributionBundle into web/bundles/sensiodistribution
Symfony2 Build Template > symfony:cache:warmup:
Clearing the cache for the dev environment with debug true
Warming up the cache for the dev environment with debug true
Symfony2 Build Template > install:
BUILD FINISHED
Total time: 11.3010 seconds
Now we want to view our application in a web browser. Use apache/nginx or some
other PHP web server. The webroot should be set to the web
directory.
If you are using a local machine and you have PHP version 5.4 or greater, you can use PHP's built in server by running the following command from the root of your project folder:
$ php -S localhost:8080 -t web
In a web browser go to /config.php
with the appropriate domain (localhost,
server sandbox or alias) and root (/
or /clientnameblog/web/
depending on
your setup).
This page should show a welcome page and some potential issues to correct or else a message stating "Your configuration looks good to run Symfony."
From a command prompt, you should also run the command php app/check.php
to
determine that the configuration is correct for the CLI execution of PHP tasks.
Once you correct any errors, you are ready to proceed.
If you attempt to go to the home page for your new application, you will see a 404 page. This is because we have no routes defined yet. Let's create a new bundle and a route.
$ app/console generate:bundle
Welcome to the Symfony2 bundle generator
Your application code must be written in bundles. This command helps
you generate them easily.
Each bundle is hosted under a namespace (like Acme/Bundle/BlogBundle).
The namespace should begin with a "vendor" name like your company name, your
project name, or your client name, followed by one or more optional category
sub-namespaces, and it should end with the bundle name itself
(which must have Bundle as a suffix).
See http://symfony.com/doc/current/cookbook/bundles/best_practices.html#index-1 for more
details on bundle naming conventions.
Use / instead of \ for the namespace delimiter to avoid any problem.
Bundle namespace: ClientName/BlogBundle
In your code, a bundle is often referenced by its name. It can be the
concatenation of all namespace parts but it's really up to you to come
up with a unique name (a good practice is to start with the vendor name).
Based on the namespace, we suggest ClientNameBlogBundle.
Bundle name [ClientNameBlogBundle]:
The bundle can be generated anywhere. The suggested default directory uses
the standard conventions.
Target directory [/var/www/clientnameblog/src]:
Determine the format to use for the generated configuration.
Configuration format (yml, xml, php, or annotation): yml
To help you get started faster, the command can generate some
code snippets for you.
Do you want to generate the whole directory structure [no]? no
Summary before generation
You are going to generate a "ClientName\BlogBundle\ClientNameBlogBundle" bundle
in "/var/www/clientnameblog/src/" using the "yml" format.
Do you confirm generation [yes]? yes
Bundle generation
Generating the bundle code: OK
Checking that the bundle is autoloaded: OK
Confirm automatic update of your Kernel [yes]? yes
Enabling the bundle inside the Kernel: OK
Confirm automatic update of the Routing [yes]?
Importing the bundle routing resource: OK
You can now start using the generated code!