CakeDC Blog


Making great things even greater

If you ever have the time, take a few seconds of your day to check this out: Though this may seem trivial to some, it was a very significant moment in the history of the CakePHP framework. Over 8 years ago now, on the 15th of May 2005, the source code for the project was released under the MIT open source license. So, why was this so important? Simply because it was the first major step which got the project to where it is today. It's also been over 6 years now since the Cake Development Corporation was established by Larry Masters, founder of CakePHP, along side the now departed Michal Tatarynowicz and Kamil Dzielinski. Many well respected developers, as well as contributors to the project, past and present, have set foot in the company, delivering the very best of CakePHP in some awesome projects, while leaving their footprint in the process. And it not only counts for those on the inside, but also the developers from the community, who openly collaborate on the CakeDC open source plugins. These have been a long and colorful six years, full of roller coaster ups and downs, twists and turns, but it's not so much the "when it was created" that counts here, but the "why". Rewind back to 2007, and Larry's proposal was simple: to create a commercial entity which allows people to live and breathe CakePHP, doing what they love day-to-day, while also providing them with a means to support their financial obligations. That's it. Sounds simple, right? Ha! That's much easier said than done, and you’ll soon find out why. Over the coming months we'll be taking an in-depth look at the history and internals of the Cake Development Corporation, giving you a unique insight through a series of posts into how this singular company does business very differently. Hope you enjoy the ride!

Working with a company that embraces o...

I've done my fair share of working for closed and "open" companies. I've recently (in July 2011) clocked over two years working here at the Cake Development Corporation, and while attending the Open Source Developers Conference (2011) in Canberra, I have had some time to reflect on my experiences with the company, and my feelings regarding my work here. Traditionally I have found that companies that claim to be pro-FOSS or open source companies are those that are making a profit, through the use of open source technologies. This is awesome. I love that the proliferation of open source software continues to grow and be adopted by traditionally closed, and proprietary software users. This produces better quality software for all of us. While CakeDC produces a large quantity of client projects that are closed source, what we do have control over is the common reusable components that we use to build and produce web applications for our clients. These are developed and refined over a number of years, and have been a pillar in our success as a company. To be able to draw on years of experience through various developers and quickly build high quality, high performance websites continues to draw attention, referrals and interest from businesses and the community alike. A decision made back in mid 2010, initially proposed by Larry Masters, our President, was to open source all of our plugins. This decision stirred a lot of discussion internally, and there were mixed opinions. While we each individually contribute to open source, speak about it at conferences, engage the community and promote open source, the concept of releasing all our internal code for public consumption for me was a little daunting. The decision was made, and we spent some time cleaning up code, making sure everything was documented and in a good state to release. You can now find all of our plugins and projects on the CakeDC Github Account. The initial load of dealing with issues and support questions, emails and contact from the public was somewhat overwhelming. We deal with issues and features very well internally, but as the process is different to open source projects we contribute to, this produced a somewhat less productive period of time for us while we adjusted our work structure and organisation to accommodate our new open source projects. We now action issues, support requests and other contact from users in a timely manner, and are receiving new and useful commits to the repositories consistently from the community. Overall the experience has been a learning one, and a very positive one. CakeDC support the staff and community in other ways. We are constantly sending staff to conferences both to speak and to attend. This allows us to talk more broadly about CakePHP, PHP in general, and other projects we use and are involved with. It also allows those attending the events from CakeDC a great opportunity to network, and learn from some of the more interesting and innovative minds of our time. This is something that we have come to do through the support of CakePHP, and through our newfound knowledge and experience in working with communities and projects openly. Working with a company like CakeDC, embracing open source and supporting a community like CakePHP is extremely rewarding and equally challenging; and a job without challenges is not what that I would want to be involved in for any long period of time. After speaking with many people working on awesome, interesting projects that are closed, or "not ready" to open source, I really count myself lucky to be working for a company that has embraced open source, contributed to the community, and demonstrates a dedication to supporting those projects and communities.

Call out to the CakePHP community

Everyone knows CakePHP has one of the largest and most loyal communities in the Open Source world, over the last few months we have been witnessing some very disturbing things happening to one of our community members. Many of you may know Jonathan Freeman over at Widget Press he created some tools that have helped many people build applications using CakePHP. He has also been a target of a patent troll suing him for patent infringement. As a software developer I find the tactics of the software patent trolls to be one of the biggest hurdles of innovation in todays development market, too many people afraid to pursue an idea because they fear being sued by a company who had an idea and was not skillful enough to build something from that idea. What upsets me even more is these trolls target people or companies who do not have the funds to stand up to "Goliath" and defend themselves. Well today we as a community need to help one of our own standup and become a David facing Goliath. What I am proposing is helping Jonathan gather some "stones" in the form of small donations from our community. If we have enough people donate we might be able to help him arm himself to defeat the troll "Goliath". We (Cake Development Corporation) are putting up $1000.00 for his defense fund on behalf of the CakePHP project and I am asking people in our community to help also. You do not need to donate this amount or you can do more if you like, any amount will be useful. But let's come together like an unexpected force and help one of our own. You can get more information here Support Widget Press against U.S. Patent 7,822,816 Updated information, if you can not donate money to help Widget Press maybe you can help  via ArticleOne on "We launched a Second Study around a #patent in the MacroSolve App Developer case, this time with $10,000 #Reward"


Tags Plugin release v1.1

Following the release an update for our Utils Plugin, we've compiled a few commits that have been finalised on the Tags plugin, bundled it and packaged for release. The tags plugin, if you've not used it, is a great and simple plugin that allows you to apply tags to any object in your existing application without modification of tables or structure. Its unobtrusive, and awesome. This latest update takes it to v1.1 with the following changes:

  • Commit [79afb1d]: Update inline docs, and test behavior removal for #5
  • Commit [0d96881]: Renamed schema to work properly.
  • Commit [982ff5b]: Minor readme update.
  • Commit [edd0e8e]: updating readme
  • Commit [db78a26]: update russian translation plural forms
  • Commit [48c1a44]: Adding spanish translation
  • Commit [3347464]: Added Portuguese translation
  • Commit [f4c4e6b]: Adding german translation file
  • Commit [44379a7]: Update license text.
  • Commit [da433cb]: Cleaned up headers for all files.
  • Commit [8c76f95]: Renamed license and readme files.
  • Commit [6e6eae4]: Renamed license and readme files.
  • Commit [99f1e89]: Added an initial Russian translation
  • Commit [93a7ad6]: Documenting identifiers in tags and the new taggedCounter behavior option
  • Commit [0242a6e]: Adding assertion to ensure trailing whitspace is removed before saving the tag
  • Commit [2de4e80]: Fixing remaining failing test cases
  • Commit [d03e1a6]: Adding the ability to have a counterCache to track the times a record has been tagged with a particular tag
  • Commit [5527079]: Fixing bug in saving tags with identifiers prepended. Refactoring code to avoid repetetions
The tags plugin received a number of ticket submissions over on lighthouse app from the community. We can't thank you enough for taking the time to submit questions, issues and suggestions to the ticket system. Its helped us fix problems and extend the plugin to become an even more useful plugin for your apps. The release is available now on the master branch of the repository, or you can download a release archive here. We hope you enjoy the update!

Using the CakeDC Tags plugin for CakePHP

This is an introduction to using the CakeDC Tags plugin for CakePHP. I'll take you through a new project creation, and the addition of the Tags plugin to your project for use with tagging a Blog model on your project. You should be able to take the skills learnt here to any other project, and start taking advantage of the Tags plugin for tagging your models appropriately. Lets get started by baking a new project: cake bake project blog1 Follow the prompts to complete the baking operation. You will now have a "blog1" directory available. Change into that directory: cd blog1 ensure that the `tmp` directory is writable: chmod -R 777 tmp Open up the `config/database.php.default` file in your favourite editor. Immediately choose to "Save as..." and save the file in the same location omitting the ".default" part of the filename. So save the file as `config/database.php`. Configure the options at the bottom to match the database credentials for your application. Mine are as follows: <?php class DATABASE_CONFIG { var $default = array( 'driver' => 'mysql', 'persistent' => false, 'host' => 'localhost', 'login' => 'dev', 'password' => 'dev', 'database' => 'blog1', 'prefix' => '', ); } For the moment, I have remove the 'test' datasource, as we won't use that right now. Go ahead and create your MySQL database, and a simple table to hold blog items: CREATE DATABASE `blog1`; USE `blog1`; CREATE TABLE `blogs` ( `id` CHAR(36) NOT NULL PRIMARY KEY, `title` VARCHAR(255) NOT NULL, `body` TEXT, `created` DATETIME, `modified` DATETIME ); Now lets bake the controller, model and views for this blogs table, in order to be able to add and edit content. Once this is complete, we'll begin integrating the tags plugin into the application. First bake the model: cake bake model blog Next bake the controller. The following bakes all the "public" actions for this controller: cake bake controller blog public And finally, the views: cake bake view all Browse around your application at the address: /blogs to begin with to ensure that your app is functioning correctly. You should be able to add, edit, delete and view blog entries. Time to get cracking on the Tags plugin. Our objective here is to tag each blog entry with an arbitrary tag at add / edit time to allow us to easily categorise content we are posting. In order to download and install the Tags plugin, I'll be using git. You can however download an archive from the github website, and extract that archive into your `APP/plugins` directory. In either case, the result will be a `tags` directory in your `APP/plugins` directory, containing the contents of the CakeDC tags plugin. From your `APP` directory (in this example, the APP directory is `blog1`), clone the tags repository: git clone git:// plugins/tags The first thing that we need to do now that the Tags plugin has been added to our project, is to create the tables required to store the tag information. These are available in schema's and migrations within the Tags plugin, so you don't need to handle the SQL yourself, just use the cake console to create the tables for you: If you prefer using the builtin CakePHP schema mechanism, or you are not sure what the "migrations" plugin is, you can create the database tables like this: cake schema create schema -plugin tags -name tags If however, you are familiar with using the migrations plugin, or you want to use the migrations plugin for this project, add the migration plugin to your project, and then run the migrations: git clone git:// plugins/migrations cake migration -plugin tags all Either method is fine. Next up, we need to add the `Taggable` behavior from the `Tags` plugin to our model to enable all the awesome functionality. Add the following variable to your `Blog` model in `APP/models/blog.php`: public $actsAs = array( 'Tags.Taggable' ); Finally, we need to add a new input for the tags on our add and edit screens, to allow users to customise the tags they want for the blog posts. Simply add a new input called 'tags' to your forms, such as the following: echo $this->Form->input('tags', array('type' => 'text')); Note that this needs to be done for both your add and edit views. You can also make this be of type `textarea`, if you need gigantic amounts of tags. `text` is fine though, to allow a good number of tags, and to minimise the input space. This is all you need to do to enable your content to be tagged! Looking back at all the instructions so far, the bulk of the content has been on how to create a new project, bake the model, views and controller, and the addition of plugins. In terms of code addition, we've only added a behavior to the Blog model, and a new input to the add and edit views. To test your tagging, use a comma to separate your tags when using the tags input. Using a comma allows you to enable users to add multiple-word tags. What now!? You can tag stuff, thats pretty cool. You probably want to look up blog posts based on tags now. Thats already provided for you in the Tags Controller quick comes with the Tags plugin. Browse to `/tags` to see the tags controller index action from the tags plugin render all the tags that you have added to your blog so far. There is a whole lot more that you can do with tagging in terms of both operation and the visual representation of the tags themselves. Stay tuned for more blog articles explaining our plugins and other interesting PHP and CakePHP code from myself and the rest of the CakeDC team. UPDATE: An excellent guide on how to style the tags with CSS has been written by @WyriHaximus, check it out here.

We Bake with CakePHP