CakeDC Blog


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 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.

Felix Geisendörfer - Jquery and CakePHP

Felix started off by baking his application. While baking his controller he added in the Javascript Helper and RequestHandler Component. This will save adding them in later. Because the demo was based on Jquery the Ajax helper could not be used. However, Felix raised a very good issue of using a helper vs. writing Javascript. His opinion is that if you want to build a heavy AJAX application you should write all your javascript. If you just need a bit of AJAX sprinkled on you can use the helper. However, helpers are difficult to use in wide applications as they abstract one language into another which is tricky. Felix talked briefly about how he organizes his javascript. He likes to have specific javascript files for each controller/view placed in js/views as well as a few utility libraries. This allows his projects to reuse general js code as well as keep the Javascript separate for each view.

Adding jquery.form

Felix recommends using the form jquery plugin for working with forms. It allows you to easily add ajax behavior to your forms. After adding jquery.forms to the layout and creating his view js file. He was able to quickly make his form Ajax-ified. A question was asked about using JSON with Ajax in CakePHP. Felix then demonstrated how you could create a JSON Ajax view. By adding Router::parseExtensions('json'); Felix then created his json layout and his json view. Extension based views need to go into a directory that shares the name with the extension. By adding a 2nd and 4th parameter to $.get() you can force a json return. $.get('/cakefest/view/2.json', {}, function(response, status){ //handle response here }, 'json'); Is an example of how to do this. A question about pagination was asked. Felix's solution was to use a selector and attach an event to all your pagination buttons.   This concludes CakeFest Argentina. I had a really great time and would like to thank everyone who came out, and everyone who presented. I would also like to thank all of our sponsors, SaniSoft, Zeadoo, WidgetPress and the CakeDC. Lastly, thanks to Mariano and Claudio for orgnanizing and hosting the event.

Garret Woodworth - Advanced console

Since we got through bake on the last talk, we are going to look at some advanced usage of bake and other consoles. The interactive console was demonstrated. With the interactive console, you can examine the routes, interact with models. Following the console demonstration, Garrett demonstrated creation of a custom shell. Building on a previous example application, garret started building a shell to generate a menu. This covered creating methods in your shell, using in() and out() as well as how to access args and params. A demo of Cakebot was next. Cakebot is the IRC bot used in #cakephp, Cakebot was also written as a CakePHP shell.

Mariano Iglesias - Internationalizatio...

Why internationalize? You can attract a larger market by making content available in additional languages. When offering international content, you need to translate both the fixed and dynamic content in the database. In CakePHP you can facilitate translation with __() and __n(). In addition content stored in the database can be translated with TranslateBehavior. Multibyte characters exist in many languages, characters outside the traditional latin character set are represented with multibyte characters. This allows for the creation of additional characters and idiomatic expresssion. There is a PHP extentsion for using multibyte strings, it provides the mb_ functions. CakePHP also provides a MultiByte class which provides all the mb_ functions for PHP4 or PHP5 installations lacking them.

Using translation in CakePHP

By using __() we can create translatable strings in our applications. You can use placeholders as well in your translation strings. It is important to use place holders as parameters such as a name can move around in a sentance based on the language. Once you have added all the __() calls, you can use cake i18n extract -output app/locale. The generated file will be placed in app/locale/default.pot Mariano then gave an example and quick walkthrough of translation and i18n. He added translated elements to the views. Then extracted the strings with the shell and created translated values with poEdit.

Translating database content

Translate behavior helps to translate any database content. All translations in CakePHP are stored in one table. Translate behavior takes a number of fields when included on a model. This indicates which fields are going to be translated. Translated fields are not needed on the table schema. The translate behavior also allows you to specify a number of languages and language specific values or you can simply add one language. Later on another language can be added. The rest of Translate Behavior works seamlessly on find() and save(). When using elements with caching. You can use a key parameter when calling element() to ensure that different languages are cached separately. Mariano's talk brought the third day of CakeFest to an end. This has been an excellent conference so far and the last day promises to be great as well.

Martin Radosta - Record level security...

Martin's presentation was based around a behavior that he wrote to provide access control using SQL. In designing a solution, martin came up with a few criteria. The solution must be generic, it only requires 4 fields on any table that will be using the behavior. It should perform quickly and not create a lot of extra queries. The solution he searched for also needed to provide a few features. It should provide permissions for read write and delete. Permissions are assigned by role, with users having many roles. This system is similar to ACL but different, in that it stores the permissions for each record. Martin's behavior uses a permission system similar to the unix file system, with a owner, group, world access. This was implemented as series of bit masks. Unlike the unix filesystems, these permissions are summed and stored as one field. The 4 fields mentioned earlier are user_id, role_id, group_id, and permissions. These four fields allow the behavior to work, both the roles and groups also use binary values to reduce the number of columns. The binary values for roles and groups are compared to those in the role and group id for records . In addition the requested permission is combined with group and role values and checked against the permissions field. Since binary values are used, roles can be combined and will always be unique. Permissions in a system like this permissions are done via a bitmask system. User values for group, and role are compared to record permissions. If the value of the bitmask meets the expectation, the record is returned. In addition to a controller, an element, action in Appcontroller and a model are used. Martin gave a quick demo of an application using his behavior. The permissions checks are all done in the SQL of the behavior. Another interesting part of the behavior is that in the behavior's afterFind() extra values are added to indicate whether or not a user can write or delete. This allows for your interface to display the correct icons. Which is a nice added bonus. I personally was really impressed with how his system was designed and how it worked. He demonstrated how his fine grained access control group. He even had a root user that was not bound by the permissions system. The permissionYou can find this project at Sourceforge the project is licensed under the MIT license.

We Bake with CakePHP