CakePHP DB Migrations v4.0 is now Stable

After months and months of delays due to work constraints, and other crap, I decided that I needed to get my head down and release v4.0 of CakePHP DB Migrations. So that is exactly what I just did!

v4.0 is now available in all its glory at the Google Code repo at http://code.google.com/p/cakephp-migrations so get it while it is hot.

You can download it here.

I plan on creating a new screencast soon(ish), that will include all the updated features and shortcuts, and will also be easier to hear me and will hopefully be a little shorter and concise. But until then, please play around and let me know if you have any questions at all.

Here's the changes taken directly from the changelog:

[*] errr...

SEO your CakePHP application

I am Search Engine Optimizing an older CakePHP application. When I started, I was looking for a solution in .htaccess, but that's not the right way.Your .htaccess is already set up to have CakePHP process all incoming URLs. It already knows what to do with your controllers and actions. The magic word is routing. Routing is your friend when you want to optimize your URLs.Of course, when you develop a new CakePHP app, be sure to think about SEO and how your URLs will look like.

CakePHP último release canditado

CakePHP que está na sua versão estável 1.1 e sua versão 1.2 chega no release candidate 3. Última versão, antes do lançamento da versão CakePHP 1.2 como estável.

O release candidate RC3, promete pois segundo os desenvolvedores o bootstrap está 10 vezes mais rápido, que o mesmo no RC2, e 5 vezes mais rápido que o conteúdo estático da sua antiga versão. Ou seja, um ganho de performance considerável.

How to get the value of the last key in an array

Very often I find myself wanting to get only the value of the last key in an array. I used to do sizeof($array); to find out the number of total elements, so I knew the position of the last value. Today I ran into a much easier way to select it. With the following line [...]

CakePHP で作成された CMS

MOONGIFT: » CakePHPを使ってCMS「Wildflower」:オープンソースを毎日紹介
MOONGIFT さんで紹介されていた CakePHP で作成された CMS の Wildflower をダウンロードしてみて、色々見てみましたし。

ソースを見ていて面白かったのが、app 以下にはコントローラもモデルもビューも置いていないこと。CMS で使う MVC は app ディレクトリと同じ階層にある wildflower というディレクトリに app ディレクトリと同じ構成で入っています。これはカスタマイズするときに、app 以下にカスタマイズした MVC を入れて、wildflower の元々のファイルを修正しなくてもいいように出来ているようです。

CakePHP のバージョンアップや Wildflower のバージョンアップ時には cake, vendors, wildflower のディレクトリのみを書き換えればいいので、自分でカスタマイズしたものはバージョンアップしてもそのまま使えるということですね。

Lancez vos sites sur orbite avec Fredistrano 1.0

Voila, on s'en approche. Fredistrano 1.0 est en phase final de test et devrait être disponible le 15 Octobre. Petite piqure de rappel au cas ou vous auriez manqué les 100 premiers épisodes. Fredistrano est une application web pour déployer automatiquement vos sites. Alors, quoi de neuf? Au menu, de nombreuses améliorations qui justifient de passer directement de la version 0.3.2 à la 1.0.0...
en lire plus

Groups do CakePHP Brasil mudou de endereço


O Gustavo Carreno, dono do Groups cake-php-pt, teve problemas com sua conta do Google e acabou perdendo a autoridade do groups. Agora ele criou um novo groups para o pessoal e pedimos a todos que atualizem seus favoritos. Agora o groups chama-se cakephp-pt (sem o hifen entre o cake e php).

Novo link: http://groups.google.com/group/cakephp-pt


Abraços e esperamos vocês lá.

CakePHP e LDAP utilizando ORM

CakePHP é um dos meus xodós para desenvolvimento WEB, com ele me sinto extremamente produtivo. Eis que surgi-o a necessidade de integrar uma aplicação com autenticação LDAP, assim como a necessidade da aplicação interagir com os campos do LDAP. Solução no CakePHP extremamente elegante, rápida e simples.

Bakery como todo bom padeiro sabe, é uma fonte de códigos para todas as áreas, eis que alguem desenvolveu um datasource para o LDAP, ou seja utilizar o data mapping do CakePHP e o ORM do CakePHP com o LDAP, assim é possível conectar no LDAP, e tratar ele como modelos na estrutura de MVC.

Bom então vamos fazer o bolo, mão na massa:



しかしだね、これ。 CompileViewって便利杉。(自慢かよw)






url("/controller/method") ?>">link

<?php echo $html->image("test.png", array("width"=>"100")); ?>



Hi all,

Just a quick post to help spread the word, cakePHP RC3 is finally here, and according to Nate's latest post at the bakery, this will be the final release candidate before they finalise the 1.2 version.

From reading through Nate's article, and the change set, It's clear that the team have worked tirelessly on iteration after iteration of performance improvements, to make the framework faster than ever before. By itself, the bootstrap process is over 10x faster than RC2, and basic requests for static content are now about 5x faster overall.

CakePHP 1.2 RC3 is Released

Just woke up to find I missed two exciting events in CakePHP land. First and most important is the release of Release Candidate 3 for 1.2. This release cannot be understated, although I think considering the amount of work that has been done on this release, we should be seeing a stable release of 1.2. I know it was only released a few hours ago, but right now there are a grand total of ONE bug. And that one bug will be fixed in 3 second, when I commit the fix ;). Go over to the Bakery and read the announcement from Nate, and you will understand the amount of work that has been done.

Although I have been a small part of this, and helped by committing some fixes and enhancements, constraints on my time and family life have kept a some what tight lid on my commitment to contributing. But I hope to change that once 1.2 goes stable.

Notas sobre Localización

¿De dónde saca CakePHP el idioma para localizar e internacionalizar?Según mi lectura del código de L10n y I18n, la cosa es más o menos así:L10n::get(), si no se indica ningún argumento, tratará de averiguarlo mediante la información procedente del navegador o bien utilizar el contenido de la constante DEFAULT_LANGUAGE, que se podría definir en bootstrap.php.Además, se supone que L10n::get() hace un Configure::write('Config.language') para establecer una preferencia de la aplicación.Por otro lado, I18n::translate(), que es la base de las funciones del tipo __(), que se usan para tener las cadenas de texto localizables (o traducibles) obtiene el idioma a través de la variable de sesión Config.language, y si no hay una establecida, lo hace a partir de Configure::read('Config.language).

Google group for CakePHP

The most useful resource for CakePHP related queries, to be honest Cakes documentation can be a little sparse at times and this has been really helpeful for me when I’m struggling with something

CakePHP | Google Groups:
The other place you should look for good code examples and tutorials is The cake bakery it can be a little hard to navigate but when you have mastered it, it is definitely a treasure trove of information.

Simple RSS feeds in CakePHP

RSS in cakephp 1.2 couldn’t be simpler, there are many options however the simplest way to do it is using the inbuilt RSS request handler.  This simply tells Cake to route requests with a specific extension (in this case .rss) to a different view, in which you can return native RSS using the inbuilt RSS helper.
The example below adds RSS support for a single action, with a single simple query.  Other examples can be found here RSS in CakePHP 1.2.
Lets assume you have a controller of “blog” and a view of “entries” i.e. www.mysite.com/blog/entries
To add RSS feed to this action, first add the ‘RequestHandler’ component in the controller’s (blog) $components attribute.
var $components = array('RequestHandler');

Setar flag no lugar de excluir registro do banco com CakePHP

Uma boa prática de programação é setar uma flag indicando que um registro foi excluido, e não simplesmente excluir o registro do banco. Por exemplo, se eu tenho um produto, que está relacionado em vários pedidos, e eu simplesmente excluo o produto, todos os pedidos que referenciam ele serão inconsistentes. Se em troca de excluir o registro do produto, eu simplesmente setar uma flag no registro indicando que ele foi excluído, eu não perderei mais essa consistência. Para excluir o produto de id 5, seria algo como:

mysql_query("UPDATE produtos SET deleted = true WHERE id = 5");

E para listar os produtos, poderia ser algo como:

mysql_query("SELECT * FROM produtos WHERE NOT deleted;");

Live Validation with CakePHP and jQuery

Marc Grabanski (1marc) has been trying to spearhead the inclusion of a jQuery Helper in the CakePHP project for some time. I know what he really wanted was some validation of forms against the defined logic in his models. So while he was staying at my house when he came to Boston for jQuery Camp and The Ajax Experience, we stayed up until 3:30am coding this puppy. Here’s the demo: http://jeff.loiselles.com/projects/cake/live-validation/

Safe Mode Error

When you have a fresh install of CakePHP 1.2 on your machine, the following error might appear: Warning: realpath() [function.realpath]: SAFE MODE Restriction in effect. The script whose uid is 1023 is not allowed to access /usr/share/php owned by uid 0 in <your_location>/HTML/cake/libs/configure.php on line 476 This can be solved by changing the following lines [...]

Why doesnt paginator remember my custom parameters when I go to page 2?

When using the paginator helper in cakephp views, it doesnt remember parts of the url that are custom for my useage.

For example:


here moderators is a parameter that helps me filter by that type. But pressing a paginator link will not include this link.

Validar relacionamento belongsTo no CakePHP

Uma prática que eu acho bastante interessante é verificar se realmente um registro existe no banco antes de associá-lo a outro. Por exemplo, suponha que se têm dois models:

class Pessoa extends AppModel {
var $name = "Pessoa";

class Aluno extends AppModel {
var $name = "Aluno";
var $belongsTo = array(
'Pessoa' => array(
'className' => 'Pessoa',
'foreignKey' => 'pessoa_id'

Eu quero que sempre que eu adicionar um aluno, o sistema valide se a pessoa a qual eu estou associando este aluno esteja cadastrada no banco. Ou seja, quero garantir que o aluno estará vinculado a uma pessoa válida.

Syndicate content