CakePHP is a powerful and robust PHP framework built around the Model-View-Controller (MVC) programming paradigm. In addition to the flexible way you can use it to build your application, it provides a basic structure for organizing files, classes and database table names - keeping everything consistent and logical.
As it is mentioned in the framework's homepage, CakePHP makes building web applications simpler, faster and require less code.
Faster and simpler is something we love at SourceLair. Therefore, in order to further facilitate the installation process of CakePHP and bring you one step closer to developing your web app, we already have most of the settings covered and the requirements met in your environment.
CakePHP in SourceLair
Starting a CakePHP web app in SourceLair is a piece of cake! You can install CakePHP and have your app up and running in 3 simple steps:
Step 1: Create a new HTML/PHP type project in SourceLair. Delete new project default files (index.html and main.css) since they won't be used.
Step 2: Copy and paste into your terminal (Ctrl + Shift + V or Cmd + V on your Mac) the following command to install CakePHP and create your app (remember to change [app_name]):
composer create-project --prefer-dist cakephp/app [app_name]
For example, I want to name my app cake: Once your set up is completed, your file explorer should look something like the following:
Step 3: Go to your project settings (the gear next to the project name) and update HTML/PHP root to the name of your app.
In my case, I set the root to 'cake'. After you Save Settings, your HTML server will automatically restart.
You can now access your web app page from your Public URL (button in the sidebar or Command Palette's Open Public URL command).
As you can see in your Public URL every requirement is met and everything is set up and ready to go.
Oops! We are still missing the database.
Connect a database to your project [Beta]
Now, this is a good chance to try out SourceLair's beta support for MySQL server.
To add a database to your project, head back to the project settings, click on Connect a database on the Database section and select MySQL.
Once your database is ready, connect to your database from your terminal
mysql -h mysql -u root -p
and create the database your app will use:
create database cake;
Now all you have to do is edit
'Datasources' => [ 'default' => [ 'className' => 'Cake\Database\Connection', 'driver' => 'Cake\Database\Driver\Mysql', 'persistent' => false, 'host' => 'mysql', //updated host 'username' => 'root', //updated root 'password' => 'c4k3-pa$$', //updated password 'database' => 'cake', //updated database
Restart your HTML server (Restart HTML server of Command Palette) and your cake web app is ready for more!
You have now installed CakePHP, created your web app and connected a database to your project.
If you're already familiar with CakePHP, happy hacking :)
Go to www.sourcelair.com and start developing your CakePHP app in minutes!