Starts With Cakephp 3 - Installation, Database Configuration
Cakephp Installation -
CakePHP uses Composer. It's a dependency management tool for PHP 5.3+ and officially supported method for installation of cakephp.
It's very useful to install cakephp. For steps to install Composer, visit- http://www.webseekerz.com/blog/steps-install-composer-windows
After successfully installation of Composer, goto root folder through command line. Like I have wamp in my D drive so the command will be
Now that you’ve downloaded and installed Composer, you can get a new CakePHP application by running:
php composer.phar create-project --prefer-dist cakephp/app [app_name]
Or if Composer is installed globally:
composer create-project --prefer-dist cakephp/app [app_name]
At my end composer is installed globally, so the command is -
D:\wamp\www>composer create-project --prefer-dist cakephp/app mycakeapp
In last it will ask for permisstion, type Y.
Created `config/app.php` file
Set Folder Permissions ? (Default to Y) [Y,n]? Y
Updated Security.salt value in config/app.php
Go to D:\wamp\www and check for project 'mycakeapp'.
Next is to connect the project with mysql.
NOTE - Convetions plays a very important role in cakephp. So please have a look on this link - http://book.cakephp.org/3.0/en/intro/conventions.html
and want to explore more than also visit http://book.cakephp.org/3.0/en/contributing/cakephp-coding-conventions.html
For a database schema,CakePHP makes certain default assumptions in terms of how certain variables, table names,
and fields will be named. Specifically, Cake expects that:
1. Table names will be plural (e.g., users)
2. The name of the primary key field will be id
3. The names of any foreign key fields will be based on the referenced table name followed by _id
(like, the foreign key into a customers table would be named customer_id).
Now create a database named mycakeapp and a tables names users.
create database mycakeapp;
CREATE TABLE users ( id INT AUTO_INCREMENT PRIMARY KEY, email VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, created DATETIME, modified DATETIME
Now come to your project and To connect your mycakeapp project to db(mycakeapp) go to - D:\wamp\www\mycakeapp\config\app.php
Do the needful changes as per shown in image and save the file.
In next step - open the command line and go to your project folder i.e. D:\wamp\www\mycakeapp
Run the command - D:\wamp\www\mycakeapp>bin\cake server
Now goto http://localhost:8765/ and check the status 'CakePHP is able to connect to the database.'
Congrats your project has been set up properly and connected with the database as well.
Now do what ever you want to do with your projects.