Cake3 … baby steps (step 1 — getting started)

(Get the app code on github.)

With the recent announcement of CakePHP 3 (beta 2) being released… it is really tempting to see where we are today.
And oh boy… how things have changed.

First things first, let’s get a hold of our the latest cake core and setup our local environment to start baking.

One thing that jumps out right away is the use of composer to install cake. This is not a requirement, but is certainly a welcome addition.

I just happen to have composer installed already, so once I “cd” into the directory of my choice, I am ready for CakePHP installation.

sudo composer self-update
composer create-project --prefer-dist -s dev cakephp/app todo

So what now?
We should have a new directory called “todo” (that’s just a name of my app). Inside you will notice a new directory called “vendor”, this is where all composer-compliant modules live by default.
Cake core is now located there and so are any other 3rd party libraries that you might use.

All of this goes to say that CakePHP now follows the same standard of autoloading (PSR-4) as many other popular PHP frameworks and libraries.
To some degree standardization, especially in loosely defined PHP world is a good thing.

Cake3 comes with its own web server, and you are welcome to test it at your leisurely time.

I’m going to go ahead and try to setup an apache virtual host and see if that works.

I need an entry in my /etc/hosts for my new “todo” app.

127.0.0.1     todo.local

Should do it…

To setup a virtual host (apache2), let’s cd to /etc/apache2/sites-available

We’ll create a new file called todo.local.conf, with the following contents:

<VirtualHost *:80>
    ServerName todo.local
    ServerAlias todo.local

    DocumentRoot /home/teknoid/work/todo/webroot
    <Directory /home/teknoid/work/todo/webroot>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order deny,allow
        allow from all
    </Directory>
</VirtualHost>

Now let’s enable the site and reload the config:

sudo a2ensite todo.local
sudo service apache2 reload

If all goes well, you should have a fresh CakePHP 3 app when you visit http://todo.local/

Now, that we are ready to start baking… we’ll take a look at some additional setup and development tools to get us going in the next post.

Related Posts

%d bloggers like this: