CakeDC Blog

TIPS, INSIGHTS AND THE LATEST FROM THE EXPERTS BEHIND CAKEPHP

Meet the CakeDC

The articles section of our site will include best practices, business advice, and technical advice, updated weekly or more often by our talented developers. Our articles will touch upon a wide range of topics from our experiences and expertise. Check back frequently for fresh thoughts from our seasoned talent, including Mark Story who was at CakeFest in Argentina providing updates daily on the talks.

As a founder of and lead developer at the Cake Development Corporation, I am proud to provide the inaugural article for the all new CakeDC.com. It has been a long and wonderful last 12 months, and CakeDC has helped bring reality to the limitless potential of our clients' projects. Like any great recipe, the ingredients of Cake Development Corporation have been hand–selected and carefully measured to create the very best blend of talent, imagination, and sophistication of any team in the world. It is my great pleasure to introduce you to our outstanding development team, as well as provide a little background about where our company has come from and where we are headed.

After spending nearly 2 years working exclusively on CakePHP and seeing its popularity growing daily, Garrett Woodworth and I realized the need for a team of experts devoted to building the best applications for clients. Therefore, in 2007, Garrett and I formed Cake Development Corporation – a company dedicated to bringing the potential of CakePHP to life while supporting its further development and aiding clients in the rapid development of web applications. In this venture, Garrett and I recognized that we had a unique and rarely realized opportunity to do what we love as our full–time jobs – and, unlike during those initial two years of development, actually get paid to do it.

As a business partner, I could not have asked for anyone better than Garrett. A key player in the development of CakePHP, Garrett continues to develop the code and drive the machines that keep users coming back for more. He is extremely passionate about the work he does and takes pride in delivering quality products that are the best of their kind, a true leader the team members can look up to. In fact, I have come to think of him as a younger brother – someone whom I respect greatly, but with whom I also spar from time to time (in a healthy way, of course).

After a short time, it became necessary to bring on some new talent. Garrett and I welcomed a third developer Jitka Koukalová, to our small family in 2007. Jitka, a developer who was active in the CakePHP community and was vital contributor to its code, was an amazing addition to our team from the beginning, and exhibited great skill in, and equally great appreciation for, our open source platform. With great attention to detail, she became instrumental in server security and maintenance. Her ability to find an issue and fix it fast along with her classy and professional demeanor would make her a mentor to future members of the Cake development team.

Florian Krämer, the next to join CakeDC, soon became our second great recruit. Florian has continually proven himself to be extremely knowledgeable when it comes to developing applications. Florian's meticulous attention to detail, outstanding work ethic, and dogged pursuit of excellence continue to be hugely important assets of our company. But more than a colleague, I consider Florian a good friend. Apart from his great skill, his fun and personable demeanor make him a great team member and someone I genuinely enjoy working with. He has a great sense of humor – or, at least, he appreciates mine!

Having seen a great deal of growth in 2007, we sought to expand our development team in early 2008 by welcoming aboard a whole new crop of distinguished developers with a great working knowledge of CakePHP and a passion for its vast capabilities. The first of this group was Yevgeny Tomenko. Yevgeny knows an astounding amount about the inner workings of application development, and I am continually amazed at his dependability and sheer speed. Since joining our team, he has become a great "go–to" person who uses his years of experience to help guide the others on the team. I really love how passionate he is about our product, and it’s great to see such a talented and focused guy enjoying his work at CakeDC.

Next, after spending some time watching Niles Rowland help others in the CakePHP IRC channel, we realized he would be a true asset to the CakeDC team. We recruited him in early 2008, and since then he has been a very knowledgeable and dependable part of the development team with a vast understanding of CakePHP and programming in general.

Soon to follow Niles were Erin McCargar and Daniel Feinberg, both of whom came aboard in May of 2008. Erin has a long history working with CakePHP and is looked up to as an advisor by those on her team. Daniel, a key person when it comes to machine learning, is very knowledgeable with CakePHP. With outstanding attention to detail and a great skill in their fields of expertise, both are willing and able to go the extra mile to make a project shine.

Finally, our most recent addition to the family is Mark Story who joined the team in November of 2008. Mark brings a lot to CakeDC; he is a core developer of CakePHP with design experience that is second to none. Mark is all about getting things done right the first time, and is great at working with others. The rest of the team truly looks up to him for both his skill and amicable personality.

This eclectic group of talent is the heart and soul of CakeDC, the family unit that makes our company stand a head and shoulders above the rest. After seeing how far we have come in the last two years, I am very excited to see what this team can accomplish next! We are looking forward to all the challenges that lay ahead and can’t wait to help our clients create a brighter, more innovative future.

Latest articles

CakePHP API Plugin

Are you creating an API in CakePHP? This task looks very popular these days, and most of our clients need an API to expose certain services to their own rich client applications, or third party services. Even if it's easy to configure CakePHP to expose a REST API, and there are other plugins that could help you building an API, we found ourselves working on specific tweaks per project to adjust the way the API was designed, so we decided to wrap all these ideas and create a specific CakePHP API Plugin including

  • Services definition
  • Integrated CRUD
  • Nested resources
  • Pagination
  • Sorting
  • Associations
  • Versioning
  • Custom Extensions (data format / transformers)
  • Self documentation
We've gathered all the best practices around API building and CakePHP and wrapped them into an easy to install and setup Plugin to be used as the foundation of your API intensive CakePHP projects. Let's walkthru some of the Plugin features using an example application: the bookmarker tutorial http://book.cakephp.org/3.0/en/tutorials-and-examples/bookmarks/intro.html We'll assume you've already created a new CakePHP application and configured it to use the bookmarker database (schema dump here http://book.cakephp.org/3.0/en/tutorials-and-examples/bookmarks/intro.html#creating-the-database).

Setting up the CakePHP API Plugin

Download the plugin first composer require cakedc/cakephp-api:dev-master Then ensure plugin is loaded in you bootstrap.php file Plugin::load('CakeDC/Api', ['bootstrap' => true, 'routes' => true]);

Now you have an API!

Test your newly configured "default" API using curl curl -X GET http://bookmarker.dev/api/bookmarks You'll get something similar to: { "status": "success", "data": [], "pagination": { "page": 1, "limit": 20, "pages": 0, "count": 0 }, "links": [ { "name": "self", "href": "http:\/\/bookmarker.dev\/api\/bookmarks", "rel": "\/api\/bookmarks", "method": "GET" }, { "name": "bookmarks:add", "href": "http:\/\/bookmarker.dev\/api\/bookmarks", "rel": "\/api\/bookmarks", "method": "POST" } ] } If you look at the provided output you'll identify we've used a JSend default renderer (status, data) and we append some extra data under 'links' (HATEOAS dynamically generated for your CRUDs) and pagination. The specific "extensions" used can be configured and custom extensions created for your specific needs, see https://github.com/CakeDC/cakephp-api/blob/master/docs/Documentation/extensions.md We'll publish a couple tutorials soon covering some of the features implemented, and explaining how did we use the CakePHP API Plugin to address specific use cases. Meanwhile, please check the documentation here https://github.com/CakeDC/cakephp-api/blob/master/docs/Documentation/overview.md

Giving back to the community

This Plugin's development has been sponsored by the Cake Development Corporation. Contact us if you are interested in:  

Create Google app for web oauth2 login step by step

Here's a step by step tutorial about how to create a web oauth2 app in Google dashboard.

Google app oauth login app 1
  • Add some cool name for your new Google app project and click "Create"
Google app oauth login app 2
  • Under "Library" section, create a new Google+ API project
Google app oauth login app 3
  • Click "Enable" in the dashboard tab
Google app oauth login app 4
  • Under "Credentials" menu, click "Oauth consent screen" tab and enter some cool name to be displayed to users when requesting their access to your application. Then click "Save".
Google app oauth login app 5
  • Under "Credentials" menu, click "Create credentials" and select "Oauth client ID".
Google app oauth login app 6
  • Now click "Web application" radio, and type your domain name and oauth callback
    • Under "Authorized Javascript origins", add your domain name: mydomain.com
    • Under "Authorized redirect URIs", add all the allowed callback url's to your application. For example if you are using CakeDC/Users Plugin, you'll need to add mydomain.com/auth/google
  • Then click "Save"
Google app oauth login app 7
  • Copy the Iauth client and secret id's into your application configuration
  • Be careful, some browsers will append blank spaces to the codes, remove any extra blank space (trim)
Google app oauth login app 8
  • Ensure the API is enabled, you can test your application now and check there is "Traffic" displayed
  You have now a Google app configured to provide Oauth2 login to your web application. Enjoy!                  

Login with Google Oauth2 in CakePHP using CakeDC/Users Plugin

This article is inspired by this question in Stack Overflow and belongs to a series of articles describing the step by step tutorial to configure CakeDC Users Plugin with the most commonly used Oauth2 providers, in this case we'll configure Google login. We'll assume you have a working CakePHP application with no Auth configured yet.

Setup

Use composer to install the CakeDC Users Plugin and the required oauth2 providers To be able to configure the callbacks in Google dashboard, you'll need to create a virtual host for you application. You don't need a working domain name, you could use something like "mydomain.dev" but Google requires a domain name (no localhost). composer require cakedc/users:@stable composer require league/oauth2-google:@stable Load it from your bootstrap.php file Plugin::load('CakeDC/Users', ['routes' => true, 'bootstrap' => true]); Run migrations to add 2 new tables: 'users' and 'social_accounts' bin/cake migrations migrate -p CakeDC/Users

Configuration

Load the Component in your src/Controller/AppController.php public function initialize() { parent::initialize(); // // ... // $this->loadComponent('CakeDC/Users.UsersAuth'); }

Create a new Google application

<?php // /config/users.php file contents $config = [ 'Users.Social.login' => true, 'OAuth.providers.google.options.clientId' => 'CLIENT_ID_HERE', 'OAuth.providers.google.options.clientSecret' => 'SECRET_HERE', ]; return $config;
  • Modify your bootstrap.php file to ensure the config file is loaded this way
Configure::write('Users.config', ['users']); //add this line before Plugin::load('CakeDC/Users... Plugin::load('CakeDC/Users', ['routes' => true, 'bootstrap' => true]); This file will override any configuration key present in the Plugin, you can check the configuration options here Configuration. Now you are ready to go to your login page and click "Sign up with Google". Upon successful login, a new user will be created in your users table and related oauth2 tokens will be saved in the social_accounts table. The new user created will have the "user" role (by default, but customizable). And based on your Auth rules, this user will be able to access your site. You are done!

Read more about CakeDC Users Plugin

Giving back to the community

This Plugin's development has been sponsored by the Cake Development Corporation. Contact us if you are interested in: We hope you've enjoyed this short tutorial covering the Google login, stay tunned for new CakePHP + Users Plugin tutorials coming soon...

BOOK A 15 MINUTES FREE
CONSULTING WITH US:
We Bake with CakePHP