Join me in writing a blog site with Symfony;

Source: Internet
Author: User

The first step:

Composer Create-project Symfony/framework-standard-edition your project name;


After creating this prototype, I execute PHP bin/console Server:run, can run up;

So now you need to connect to the database: My database is PostgreSQL

Write a database creation script such as my

Create UserMyBlog withPassword'MyBlog' ;ALTER USERMyBlog withPASSWORD'MyBlog';Create DatabaseMyblog_dev withEncoding='UTF8' ;Create DatabaseMyblog_prod withEncoding='UTF8' ;Create DatabaseMyblog_test withEncoding='UTF8' ;Grant  All Privileges  on DatabaseMyblog_dev toMyBlog;Grant  All Privileges  on DatabaseMyblog_test toMyBlog;Grant  All Privileges  on DatabaseMyblog_prod toMyblog;\connect Myblog_dev;Create Schemaextensions;CreateExtension HstoreSchemaextensions;ALTER DATABASEMyblog_devSETSearch_path to"$User", Public, extensions;Alter DatabaseMyblog_dev owner toMyBlog;Alter Schema  PublicOwner toMyBlog;Alter SchemaExtensions owner toMyBlog;GRANTUSAGE on SCHEMA  Public  toMyblog;\connect Myblog_prod;Create Schemaextensions;CreateExtension HstoreSchemaextensions;ALTER DATABASEMyblog_devSETSearch_path to"$User", Public, extensions;Alter DatabaseMyblog_dev owner toMyBlog;Alter Schema  PublicOwner toMyBlog;Alter SchemaExtensions owner toMyBlog;GRANTUSAGE on SCHEMA  Public  toMyblog;\connect myblog_test;Create Schemaextensions;CreateExtension HstoreSchemaextensions;ALTER DATABASEMyblog_devSETSearch_path to"$User", Public, extensions;Alter DatabaseMyblog_dev owner toMyBlog;Alter Schema  PublicOwner toMyBlog;Alter SchemaExtensions owner toMyBlog;GRANTUSAGE on SCHEMA  Public  toMyBlog;
View Code

Create a database based on a script.

The second step, let your program this prototype program to connect to the database:

Find Config.yml

Copy code:

# Doctrine ConfigurationDoctrine:    dbal:        driver:   %database_driver%         host:     %database_host%        port:     %database_port%        dbname:   %database_name%        user:     %database_user%        password:%database_password%         CharSet:  UTF8
View Code

Find Parameters.yml and Parameters.yml.dist.

Connect your database name (config-like):

# This file is auto-generated during the composer installparameters:    database_driver: pdo_ Pgsql    database_host: 127.0.0.1    database_portnull    database_name: Database name    database_user: database user name    Database_password: database Password    mailer_transport : SMTP    mailer_host: 127.0.0.1    mailer_user:     mailer_password :     Secret: Thistokenisnotsosecretchangeit
View Code

This is connected to the database;

-----------------------------------------------

The third step is to start writing bundles according to your business needs:

Note: The true meaning of bundles is that it exists as an independent component of software that can be reused. If Userbundle cannot be used "as is" in another Symfony program, it should not be a bundle. In addition, if Invoicebundle relies on productbundle, there is no need to divide them into two bundles.

Here are the commands for wearing bundles: I'm not going to create a new bundle here.

PHP bin/console generate:bundle--namespace=appbundle--dir=src--format=annotation--no-interaction

Join me in writing a blog site with Symfony;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.