サクサク読めて、アプリ限定の機能も多数!
トップへ戻る
Switch 2
cakebaker.42dh.com
My current testing tool of choice is Cucumber. Cucumber itself integrates well with other tools. One of those tools is Webrat, which allows you to access your application without a browser and to perform actions like clicking on a link or filling out forms. It works fine with Rails 2.3.x, but not with Rails 3 (at least I was not able to make it work, and on RailsPlugins.org the current version of
From emails I receive it seems like there is a bit of confusion about what the terms 2-legged OAuth and 3-legged OAuth mean. I hope I can clear up this confusion with this article (and don’t contribute more to the confusion…). In short, they describe two different usage scenarios of OAuth involving two respectively three parties. 3-legged OAuth describes the scenario for which OAuth was originally
Yesterday, Tarique Sani mentioned in a thread in the CakePHP Group “order by field”. I know “order by”, but I never heard about “order by field” (which seems to be MySQL-specific). Ok, let’s do some examples to learn more about it. We will use the following countries table: [1] => USA [2] => Germany [3] => Russia [4] => Austria [5] => China [6] => Switzerland Now, we don’t want to sort them by the
This weekend the RailsBridge people have organized a bugmash with the motto “Do One Thing for Rails 3”, and so I took the opportunity to experiment a bit with the coming Rails 3. After following the instructions for creating a new Rails 3 app (using the –database=mysql parameter for the “rails” command) I noticed that the application tried to access the (not existing) production database. That was
In a recent comment David Cournoyer shared a tip about extending CakePHP’s core components and I think it could also be useful for others. Let’s say we want to add a method to the request handler component. And so we create a new class which inherits from the request handler component: // app/controllers/components/my_request_handler.php App::import('Component', 'RequestHandler'); class MyRequestH
Today I released a new version of the OpenID component. Three changes made it into this release: Almost all external libraries are now included in the package to make the installation a bit easier. Included are the required PHP OpenID library and PEAR DB (which is used if you want to store the OpenID data in the database). Not included is the EAUT library as I think this standard is dead (i.e. nob
So far I used Subversion as version control system and my usual workflow is quite simple: IDE => Subversion repository => live web application I develop on my local machine, commit the code to the Subversion repository on the server, and finally export the code from the repository to the live application. That works fine. However, as I wasn’t able to connect to Subversion repositories from Netbean
As you probably have heard, RC3 of CakePHP 1.2 has been released today (together with a bug fix release of CakePHP 1.1), see also the official announcement. Upgrading NoseRub, which has to act as my guinea pig in such cases, from RC2 to RC3 was a piece of cake. In the “app” folder I had to update the following files as there were some minor changes in them: app/webroot/js/vendors.php app/webroot/c
A growing number of APIs support OAuth, i.e. it is possible to give service A access to service B without giving B’s username/password to A. In this article I’m going to show you how to use OAuth-enabled APIs with CakePHP (and the OAuth consumer component I have written). First, there are some preparations necessary, namely the download of the required files: Get the OAuth component and place its
In an earlier post I asked what’s missing for testing a CakePHP application. In the meantime I created a test suite which implements the missing features mentioned in that post. In this article I will introduce this new test suite. (please notice that I don’t know yet whether this test suite will become the official test suite) Ok, let us start with the installation, which is simple (I assume you
With changeset 6918 a new behavior has been introduced to CakePHP: Containable. It’s a mix of the original Containable behavior by Felix Geisendörfer (aka the_undefined) and the Bindable behavior by Mariano Iglesias. To use the new behavior, you either have to add it to the $actsAs property of your model: class Post extends AppModel { var $actsAs = array('Containable'); } or you can attach the beh
If you use Eclipse PDT you probably noticed that there is no code completion in the view for helpers. The reason for that behavior is that Eclipse doesn’t know anything about CakePHP’s magic and so cannot provide code completion. Now someone called “voidstate” posted a little trick in the CakePHP Google Group which makes it possible to get code completion in the view for helpers. For this purpose
A question asked from time to time in the IRC channel is: “How can I use helper X in my controller?”. Well, helpers are not thought to be used in controllers. They are designed to be used in views. So whenever this question arises, you have to ask yourself (or others) whether you are doing something wrong and if there is no better solution. Nonetheless, in some (rare) cases it can be useful to use
Sometimes it is quite handy if the users of an application can simply click on some text to edit it. Adding such a feature to your application is not very difficult as you will see. At first we have to get the Jeditable plugin (plus the JQuery library if you don’t have it already) and place it in app/webroot/js. In this folder we also create a js file which will contain the Javascript code we have
A common use case in an application is the registration. The user has to provide a username and a password, and often additional information, too. If you are using OpenID, the registration process can be simplified quite a bit for the user. Thanks to the OpenID Simple Registration Extension (or short “sreg”) your application can get some common data directly from the OpenID provider. In particular
Just uploaded a new version of the OpenID component I wrote sometime ago. It uses now version 2.0.0 of the PHP OpenID library, which supports the OpenID 2.0 specification. As the API has changed a bit, let me make a simple example to show you how the component is used. First we create the login form: <?php // app/views/users/login.ctp if (isset($message)) { echo '<p class="error">'.$message.'</p>'
Up to now there was no PHP support for Selenium Remote Control, i.e. you couldn’t integrate your Selenium tests with a testing framework like SimpleTest. On PEAR there is now a package called Testing_Selenium which makes it easy to use PHP and Selenium Remote Control together. To use them you need PHP5 and a JRE (Java Runtime Environment) version 1.5 or higher. The installation itself is simple. H
Recently I got asked how you could paginate data from a HABTM (hasAndBelongsToMany) relationship. As the answer could be interesting for others, too, I will show a potential solution here. Let’s say you have the two models Category and Product, and you want to paginate the Products of a certain Category. Your table definition looks like: create table categories ( id int(11) not null auto_increment
Ever wondered what happens if you do a request in your CakePHP application? Brandon Parise has drawn a diagram in which he shows in detail all involved steps to get from a request to the rendered view. It is ideal for those who want to know what’s going on behind the scenes, but too detailed for those looking for a high-level overview. Diagram: http://www.cakecollab.org/lifecycle.png (this diagram
One thing I often wished to have when using Git was the ability to autocomplete Git commands and branch names. As I had to learn this week from Markus Prinz’ article A few of my Git tricks, tips and workflows, Git comes with an autocompletion script for the Bash shell. But to use the autocompletion, you have to enable it. To do that, add the following snippet to your ~/.bashrc file (if you are usi
If you write an application which the user must install on his own server, you have to think about the installation process of your application. In this article I will describe the approach I have used in my application. This approach is heavily inspired by the one used by WordPress. That means the user has to create the database and to define the database settings in app/config/database.php himse
This article is outdated, there is a newer tutorial! You probably heard about OpenID, the open, decentralized, free framework for user-centric digital identity. It allows you to authenticate with just your URI and a password for all services which support OpenID. The integration of OpenID into your (CakePHP) application is rather simple, and I wrote an OpenID component to make it even easier. Here
Up to now the validation support consisted of four constants (VALID_NOT_EMPTY, VALID_NUMBER, VALID_EMAIL, and VALID_YEAR), everything else you had to do yourself. The new validation class in CakePHP 1.2 is a bit more powerful ;-) The aforementioned constants still work in 1.2, but they are deprecated, so for new code you shouldn’t use them. The usage of the new validation rules follows the followi
In this post I will describe how to upload and store a file in the database. Yes, you read correct, I will describe how to store a file in the database. I know, a lot of people do not recommend storing files in a database due to performance reasons. Of course, this is an important point you have to consider when you design your application. The reasons why I store files often in the database are:
このページを最初にブックマークしてみませんか?
『cakebaker - baking cakes with CakePHP』の新着エントリーを見る
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く