1. set virtual host
# /etc/httpd/conf/httpd.conf NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1> ServerName symblog.dev DocumentRoot "/var/www/html/symblog.dev/web" DirectoryIndex app.php <Directory "/var/www/html/symblog.dev/web"> AllowOverride All Allow from All </Directory> </VirtualHost>2. set hosts
# /etc/hosts 127.0.0.1 symblog.dev3. set permission app/cache and app/logs
chmod 777 cache
chmod 777 logs
II. CREATE BUNDLE
c:\wamp\www\jobeetsymfony2.com>php
app/console generate:bundle --namespace=Blogg
er/Bundle
--format=yml
Welcome to the
Symfony2 bundle generator
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 BloggerBundle.
Bundle name
[BloggerBundle]: BloggerBundle
The bundle can be generated anywhere. The suggested default
directory uses
the standard conventions.
Target directory
[C:/wamp/www/jobeetsymfony2.com/src]: C:/wamp/www/jobeetsymfony
2.com/src
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]? y
Summary before
generation
You are going to generate a
"Blogger\Bundle\BloggerBundle" bundle
in "C:/wamp/www/jobeetsymfony2.com/src/" using the
"yml" format.
Do you confirm
generation [yes]? y
Bundle generation
Generating the bundle code: OK
Checking that the bundle is autoloaded: OK
Confirm automatic
update of your Kernel [yes]? y
Enabling the bundle inside the Kernel: OK
Confirm automatic
update of the Routing [yes]? y
Importing the bundle routing resource: OK
You can now start
using the generated code!
III. ASSETS - symlinks for public pakage in src folder to web folder
IV. GENERATE ENTITIES
V. DATABASES
Next update the vendors to reflect these changes.
This will pull down the latest version of each of the repositories from GitHub and
install them to the required locations.
Now let’s register the bundle in the kernel located at app/AppKernel.php.
We are now ready to update the database to reflect the entity changes. This
is a 2 step process. First we need to get Doctrine 2 Migrations to work out the differences
between the entities and the current database schema. This is done with the
doctrine:migrations:diff task. Secondly we need to actually perform the migration
based on the previously created diff. This is done with the
doctrine:migrations:migrate task.
Run the following 2 commands to update the database schema.
Your database will now reflect the latest entity changes and contain the new
comment table.
III. ASSETS - symlinks for public pakage in src folder to web folder
php app/console assets:install web --symlink
If you are using an Operating System that doesn’t support symlinks such as Windows you will need to drop the symlink option as follows.
php app/console assets:install web
This method will actually copy the resources from the bundles public folder into the applications web folder. As the files are actually copied, you will need to run this task every time you make a change to a bundles public resource.
IV. GENERATE ENTITIES
php app/console doctrine:generate:entities Blogger
V. DATABASES
create database : php app/console doctrine:database:create
create table : php app/console doctrine:schema:create
Next update the vendors to reflect these changes.
composer install
composer update
http://getcomposer.org/doc/00-intro.md#installation-windows
In Linux : - get composer : curl -sS https://getcomposer.org/installer | php
- install composer :
php composer.phar install
add example data : php app/console doctrine:fixtures:load
***Doctrine 2 Migrations
The Doctrine 2 Migrations extension and bundle do not come with the Symfony2 Standard Distribution, we need to manually install them as we did with the Data Fixtures extension and bundle. Open up the composer.json file located in the project root and add the Doctrine 2 Migrations extension and bundle to it as follows."require": {
// ...
"doctrine/doctrine-migrations-bundle": "dev-master",
"doctrine/migrations": "dev-master"
}
composer update
Now let’s register the bundle in the kernel located at app/AppKernel.php.
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
// ...
);
// ...
}
Run the following 2 commands to update the database schema.
$ php app/console doctrine:migrations:diff
$ php app/console doctrine:migrations:migrate
VI. CREATE DOCTRINE REPOSITORY
php app/console doctrine:generate:entities Blogger\Bundle
php app/console doctrine:schema:update --force
VII. Adding Form Comments
php app/console generate:doctrine:form BloggerBlogBundle:Comment
X.CLEAR CACHE
c:\wamp\www\jobeetsymfony2.com>php
app/console cache:clear --env=dev
Clearing the cache for the dev environment with debug true
c:\wamp\www\jobeetsymfony2.com>php
app/console cache:clear --env=prod
Clearing the cache for the prod environment with debug false
Không có nhận xét nào:
Đăng nhận xét