Blog

How to Create your own Scaffolding plugin for CakePHP 2

CakePHP’s builtin scaffolding is great but sometimes I wish it would do more or behave a little differently. Until recently, I assumed this couldn’t be accomplished with the way scaffolding was baked in. Thanks to the clever way CakePHP handles includes, we can easily use our own scaffolding implementation by adding 2 lines to AppController.

In this tutorial we will built a scaffolding plugin that is aware of the TreeBehavior (continue reading…)

Keywords:

  • pronique com
  • cakephp generate list scaffolding
  • cakephp 2 1 tutorial

CsvExport Behavior for CakePHP 2

This behavior is the exact opposite of the CsvImport behavior included in the Utils plugin from CakeDC. This Behavior will end on github but for now, here is the source code and instructions on how to use the Behavior. (continue reading…)

Keywords:

  • cakephp csv

Enable CSV Import for all controllers/models in a CakePHP 2.x project

CakePHP LogoI often use phpMyAdmin to import csv data into projects I am building, this can be tedious as phpMyAdmin requires the number of fields and field order to match exactly for the csv import to work.

This frustration prompted me to explore the (continue reading…)

Keywords:

  • cakephp csv import
  • cakephp import csv
  • how to read csv file in cakephp
  • import csv to database in cakephp sample code

[CakePHP] Modeling a simple accounting system with estimates, invoices, and payments.

Database tables and Model classes are where most CakePHP applications begin. With this example, we will focus on Model associations rather than providing a complete tutorial of an application. Consider this a solid foundation for building an Accounting Web App, this is the M in MVC.

The idea behind what we are modeling today is a simple accounting web app similar to Freshbooks or something QuickBooks offers. The model definitions and relationships are as follows. (continue reading…)

Keywords:

  • cakephp accounting system
  • cakephp invoice
  • invoice program in cakephp

Installing CakePHP 2.1 with git clone

If you have ssh shell access to you web server installing CakePHP very simple using git.
First, determine if you have git installed. (continue reading…)

Keywords:

  • git cakephp

Install and reuse CakePHP across multiple projects

Update: I have created a command line tool that provides the functionality explained in detail below. Check-out CakeCore and learn more.

How to maintain one copy of each major version of the CakePHP Core library. Making upgrades to new versions of the framework effortless even across many applications.

I use CakePHP for the majority of web-based applications I create. Before developing this convention I would end up with many redundant copies of the Core library floating around taking up disk space, and making upgrade tedious. (continue reading…)

Keywords:

  • cakephp multiple apps

Installing MongoDB on Windows the WAMP way

This guide is geared towards web developers using wamp. As you know, wamp keeps your filesystem tidy by installing apache, mysql, and php all inside c:\wamp. My setup is a Windows 7 64bit machine running wamp 32bit (Why run wamp 32bit on Windows 7 64bit?). Although untested on each, this guide should also work for Windows XP, Vista, and Windows Server variants.

MongoDB is a open source, high performance,NOSQL database server(mongod.exe) and shell(mongo.exe) developed by 10gen. MongoDB win32 binaries are available in both 64bit and 32bit flavors. The win32 binaries are packaged as a very simple zip file containing only the binary executables, no installer, and no example config files.

Lets get started! We will install mongodb into the c:\wamp directory, create conf,data,log directories, and configure mongod to run as a windows service. (continue reading…)

Keywords:

  • wamp mongodb
  • InstallingMongoDBonWindowstheWAMPway-PRONIQUESoftware
  • mongodb wamp
  • wampserver mongodb
  • wamp mongo
  • install mongodb wamp
  • installing phpdriver for mongodb for wamp on windows xp
  • mongo db on wampserver
  • wamp and mongodb
  • how to use mongodb with wamp

Howto recover deleted php files using scalpel

Several times in the past I’ve accidentally overwritten a file or used a greedy wildcard with rm -rf. If you find yourself in this situation, don’t worry, scalpel can recover your file(s). My experience using scalpel was on a Ubuntu server but the tool will work on other linux distros including Redhat, Fedora, Debian, and more.  A Windows and Mac OS X build is also available.

scalpel is my tool of choice because it will recover files from the newer ext4 filesystem, which is the default filesystem for Ubuntu since (continue reading…)

Keywords:

  • scalpel php
  • scalpel recover text files
  • scalpel recover php files
  • foremost recover text file
  • how can i use a wildcard with scalpel in linux?
  • how to recover php files in one piece
  • php get deleted file contents
  • recover deleted php files
  • Scalpel requires libtre and libtre-dev

Mediawiki CSV Import ver 2.2.1 Released (Coupon Codes!)

PRONIQUE Software is proud to announce a new version Mediawiki CSV Import. Version 2.2.1 introduces the Dataset Library, a collection of contributed datasets that you can import and use to build your own Mediawiki Import files.

You must be a registered user to import or download the datasets. Membership is only $7.99 (one time) and helps support the development of the tool. It’s still FREE to register and use the tool however exports are limited to 15 pages until you upgrade.

To mark the new release and spark interest we are giving away 25 free accounts! Use one of the coupon codes below to upgrade to a Paid account. Once you create an account, login and enter the coupon code on the Upgrade page.

SD3YD7
FD3GD3
MA1JT9
TA9DT5
TE4W2D
SF7XK4
SD8GW6
BN2DF4
OK5RT3
EP8GF4
ED9GR3
SW2FR3
FRIDAY9

Learn more and signup for a FREE account at http://mwcsvimport.pronique.com/


CakePHP: Reorder lft rght columns in Tree models

CakePHP LogoIf you are using the Tree Behavior sometimes the lft and rght columns get out of sync, especially if you are adding and deleting records during development.  Add the following method to your app/app_controller.php or controller of your choice.

    /**
    * This is a maint function to recover/reorder the 
    * lft/rght columns of a tree model.
    * 
    */
    public function recover_tree( ) {
        $modelClass = $this->modelClass;
        if ( property_exists( $this->$modelClass->Behaviors, 'Tree' ) ) { 
            if ( !$this->$modelClass->recover() ) {
                echo 'Error recovering acl tree';
            } else {
                echo $modelClass . ' reordered.';
            }
        } else {
            echo $modelClass . ' is not a tree model';
        }
        exit;
    }

CakePHP’s Acls implementation also uses this same Tree table structure. Since Acos and Aros often don’t have their own controllers the following method will allow you to reorder the lft rght columns in one shot. Again, add this to your AppController or controller of choice.

    /**
    * This is a maint function to recover/reorder the
    *  lft/rght columns of the aco and aro models.
    * 
    */
    public function recover_acl_tree( ) {
        App::Import('Model', 'Aco' );
        App::Import('Model', 'Aro' );
        $Aco = new Aco;
        $Aro = new Aro;
        if ( !$Aco->recover() || !$Aro->recover() ) {
            echo 'Error recovering acl tree';
        } else {
            echo 'Aros and Acos reordered.'; 
        }
        exit;
    }

These methods/actions are meant to be called manually as you feel needed. If you would rather call them from other controller actions I would suggest prepending ‘_’ to the method names making them private/protected methods rather than url accessible actions.

cakephp tree reorder


Copyright © 1996-2012 PRONIQUE Software. All rights reserved.