CakeDC Blog

TIPS, INSIGHTS AND THE LATEST FROM THE EXPERTS BEHIND CAKEPHP

Jim Lerza - Origami - Automating the p...

Jim is from Expungement Assitance Services. They run clearMyRecord.com which helps people get their criminal records expunged. Origami is a proposed solution for automating criminal records relief in the United States. The application helps manage all the different types of forms that need to be filled out. All these forms need to be collected and standardized so that the data can be normalized. This helps to automate future applications, and streamline the the user experience. There was an existing application that had a pile of legacy code. This legacy code was partly written in mandarin, and had a difficult to understand naming convention. The database was a mess, and the identification system was jumbled and difficult to follow. There were many challenges and requirements that led them to choose CakePHP, including needed features, time, funding and other constraints. Their team faced a few Cake specific challenges. They had trouble with OOP practices, getting sandboxes setup, and some members of their team had challenges with the API documentation and the contents of the book. They also had difficulties figuring out how to implement specific features. Afterwards there was a quick demonstration of the clearMyRecord application and a sample form was filled out. Even though the team at EAS seemed to face a lot of challenges. Jim seemed to be fairly happy with their choice in frameworks, and would make the same choice again.

Ryan Petersen - Collective Intelligence

Collective intelligence is a shared or group intelligence that emerges from the collaboration and competition of many individual. Some examples would be Amazon's book recommendations. Netflix uses collective intelligence to track their stock and supply changes, and more accurately allocate their resources. Recommendations requires something to track like sales, or user preferences. A group of users is also required, the larger the group the better. A research survey found that a random sample of less that 1500 people will be the ideal and most efficient sample size. There are many ways to estimate preferences. The most simple and basic one is Euclidean distance scoring. Pearson Correlation Score, also uses 2 axis to plot out the points, this method is used by amazon and delicious.

Stochastic Optimization

Theory of being able to optimize things. Requires a cost function, it is the most important part of optimization as it gathers the dataset used. Ie. Execution time of a request, time used for data integrity, error handling/logging, client bandwidth, data queries/filtering. When doing metrics and calculating cost you can use a unit cost and parts to unit. This will allow you to control and manage the final output. Depending on what you are measuring, you need to control different weighting. Random searching is an inefficient process, as it is difficult to determine whether you are moving toward or away from where you want to be. Writing unit costing functions is a specific to the task you want to achieve. When doing optimization with cost optimization, you need to be aware of local minimums. Once you have reached a new minimum or optimized level you need to do additional testing by expanding the range in either direction. By expanding your test range you help to ensure that you have found a more accurate low cost point, and aim to ensure that you haven't found a local low point. Genetic Algorithms, and Hierarchal Grouping are other statistical methods to look into. Ryan is going to be releasing both Pearson Correlation and Euclid distance scoring will be released on the The bakery and SerenitySoft So check back for some code.

Martín Sarsale - Death of Apache Long ...

Lighttpd runs as one thread there are no forks, and only one thread. Lighttp is not good for large virtualhosts. It also bottlenecks on the disk speed. It is however good, when you have a single large application or need to total control. Lighttpd has several modules that are analogous to Apache such as Rewrite, Auth, Expires etc. Configuration files in lighttpd are very dynamic and allow for variables, regular expressions and if blocks. By using caching well you can reduce the number of requests made. By using Asset.timestamp = force you will get query strings that contain a querystring with the last modified datetime. You can use a configuration script to set the expiry time for these requests.

Lighttpd and PHP.

Lighttpd doesn't use a PHP module like Apache. Instead it connects to PHP via a socket or TCP/IP. Often this is done with FastCGI. This decoupling of PHP processor and webserver allows you to scale horizontally easily by adding more PHP servers. You can implement this with static resources as well. Static files can be easily routed to alternate machines based on regular expressions done in the config files. Unlike apache which handles and processes each request Lighttpd works more like a pipe connecting inputs to outputs, or between the client and the servers. LUA scripting is a simple scripting language that is built into lightttp. For example sending a random image. This can be done with raw PHP, PHP and X-Sendfile, or by using a LUA script. The LUA script is ~400% faster when compared to PHP. This demonstrates one of the many advantages that Lighttpd can offer over Apace There are similar performance gains to be made when using LUA scripts with full page caching. Lighttpd gives you a lot more control on how you configure your severs. You can easily fix problems with CPU use or HDD disk by adding more resources to the appropriate area. And since you can have multiple file servers attached to one Lighttpd process. Swapping out or adding extra disk server is not a difficult thing to do. Lighttpd seems like a viable and exciting alternative to Apache that I would consider using in the future.

BOOK A 15 MINUTES FREE
CONSULTING WITH US:

Garrett Woodworth - CakePHP console ba...

Garret's talk focused on getting command line tools setup. Before getting started on that he covered how to setup a virtual host for a cake project. Once he got into the cake shell, he covered the basic core shells and how to call shells. Garret then used bake to create a new project and a database config file. Using cake bake project and cake bake db_config. Up next was creating a schema file with cake schema generate. The schema file was populated with a few tables to store some information about restaurants. A question was raised about adding and removing columns. Garret demonstrated that as well. Baking models controllers and views was up next. Using the previously created restaurants table, garret walked through baking a model, controller, and some views. At first a scaffold was used but the views were made concrete very quickly. The talk ended with a quick tour of the API and TestSuite shell, and how to look up different methods on different classes. Testing was up last and garret ran the freshly baked tests from the CLI. Garret will be continuing this talk later this week.

Mariano Iglesias - CakeFest.org: Theme...

Mariano is presenting about creating a complete website with a framework. Specifically Mariano will be talking the CakeFest site. This should help to show how to apply the theories that have been talked about up to today and throughout the rest of the week. cakefest.org was developed for the first Cakefest, it is multi-user, multi-event, multi-language application, that was needed to scale for mulitple events. It was built with Themes, Behaviors, pagination, security, Acl, Auth and i18n.

Using themes to 'reskin' a site

Themes are set by using Controller::$view = 'Theme'; and setting Controller::$theme = 'themeName'. The theme views allow you to override specific views and leave others as they are in the core application. In the CakeFest site the theme was tied to a url parameter. This allowed search engines to crawl and consume all of the content. A cookie would not allow that.

Behaviors

Behaviors were used to reduce and abstract much of the model code. Behaviors allow you to reuse code not only between models in this application but others as well. Mariano provided an example with the tokenaable behavior used in resetting passwords.

Security

You can use security to stop form manipulation, and force actions to only accept specific HTTP requests. For example using requireGet('login') will not allow a POST or any other request type other than GET to login. Security component automatically secures all forms built with form helper. A hash key is added to each form, and if the hash key doesn't match after post, the request is sent to a blackHole. Using the security component is an easy way to keep forms secure and safe.

Email Component

Email component was used to send emails from the CakeFest site. It used templates and attachments which are both native to the EmailComponent.

RSS and RequestHandler

By using RequestHandler and Router::parseExtensions() we don't need to add a separate action for the RSS and non RSS versions of the news listings. With this approach we also use a separate view file for the RSS format. Another benefit is that we are not required to set the headers manually or switch the layout. This helps to save time and effort, as the layout switching and header content types are generated automatically.

We Bake with CakePHP