Standard CakePHP behaviors

Keyboard Shortcuts

The ContainableBehavior class allows users to contain just the related CakePHP model associations in find results, excluding the associated information that isn't relevant. In this training video, Justin Yost explores one of the most important standard CakePHP behaviors, ContainableBehavior.

- CakePHP has some pretty standard behaviors…that we can go ahead and start learning about.…The Containable Behavior is one of the most useful behaviors…and it should be enabled in any CakePHP application.…Let's learn about it right now.…It's a pretty easy behavior…to start wrapping your head around.…First, we want to open up the AppModel class,…which is in app, Model, AppModel,…and we want to scroll down to line 32.…This is our core AppModel class.…We want to add in our new behavior.…

To add in our new behavior,…we need to add in a new property for the model class.…The property is actsAs.…It's an array, much like our components,…and we add in the name of the behavior.…In this case, the name of the behavior is Containable.…Now our property is enabled.…Let's see exactly what happened.…The property is enabled now.…Let's try it out.…Let's open up our UsersController…at app, Controller, UsersController.…And we want to go down to the bottom of our controller…and we want to add a new method called info.…

So on line 105,…

Resume Transcript Auto-Scroll

Author

Released

12/4/2015

CakePHP is a registered trademark of Cake Software Foundation, Inc.. Cake Software Foundation, Inc. is not affiliated with Lynda.com, nor does it endorse, sponsor, or otherwise support Lynda.com services.

CakePHP is a critical framework for PHP developers. It helps them build complex web applications faster and more efficiently than coding by hand. If you want to use CakePHP in your own development workflow, this is the place to start. Justin Yost provides an overview of the underlying MVC pattern in CakePHP, and the installation and configuration process for the framework. He shows how to use CakePHP shells and the console to build your first basic CakePHP app, and then discusses each application element in depth: controllers, models, views, components, behaviors, helpers, and utilities.

In later chapters the course gets a little more advanced. Watch these videos to learn how to write a custom shell, extend CakePHP with plugins, and write unit tests to identify and eliminate bugs in your code. Justin also shows how to add security to your CakePHP apps with a basic user authentication system.

NOTE: While CakePHP 2 is a slightly older version of the framework, it's still an actively developed tool that is useful for maintaining and updating web applications. Many of the conventions and problem-solving approaches in this course are also applicable to CakePHP 3.

Topics include:

Comparing CakePHP 2 and CakePHP 3

Installing and configuring CakePHP

Using different CakePHP shells

Creating CakePHP controllers

Saving data in a CakePHP model

Creating views

Using components to share functionality between controllers

Using behaviors

Formatting data with helpers

Developing faster with CakePHP utilities

Writing a custom CakePHP shell

Creating a custom plugin

Testing CakePHP applications

Authorizing users of CakePHP applications

Skill Level Intermediate

4h 55m

Duration

42,320

Views

Show MoreShow Less

Q: I can't open the exercise files. What's this .7Z extension?

A: The .7Z extension is for a 7-Zip file. 7-Zip is an open-source file compression standard that is similar to a ZIP file, but it has a much better compression rate in certain situations. For the exercise files in this course, using a standard ZIP file would have added around 150MB to the download size, so we opted for a more efficient format.

To extract the .7Z file, you'll need some free software. If you visit 7-zip.org, you can find free, open-source software for Windows. For Mac users, please see kekaosx.com to download Keka, a free application that can do the same. For those with software security policies in place, Keka is also available on the Mac App Store for $1.99.

Skills covered in this course

Course Retiring Soon

Learning CakePHP 2 will be retired from the lynda.com library on March 30th, 2018. Training videos and exercise files will no longer be available, but the course will still appear in your course history and certificates of completion. For updated training, check out Learning CakePHP 3 in the lynda.com Online Training Library.

Continue Assessment

You started this assessment previously and didn't complete it. You can pick up where you left off, or start over.

Start My Free Month

Start your free month on LinkedIn Learning, which now features 100% of Lynda.com courses. Develop in-demand skills with access to thousands of expert-led courses on business, tech and creative topics.