Skip to content

Instantly share code, notes, and snippets.

[alias]
au = update-index --assume-unchanged webroot/index.php plugins/empty tmp/cache/blog/empty tmp/cache/cms/empty tmp/cache/core/empty tmp/cache/models/empty tmp/cache/newsletter/empty tmp/cache/persistent/empty tmp/cache/views/empty
@ceeram
ceeram / AppController.php
Created January 3, 2012 21:12
example for loggin in guests in CakePHP 2.x
<?php
App::uses('Controller', 'Controller');
class AppController extends Controller {
public $components = array(
'Auth' => array(
'authorize' => 'Controller',
),
'Session'
@ceeram
ceeram / readme.textile
Created January 6, 2012 21:19 — forked from josegonzalez/readme.md
Example Readme for CakePHP plugins that use MIT license

[PLUGIN NAME] Plugin

[ONE LINE DESCRIPTION OF PROJECT]

Background

[A PARAGRAPH DESCRIBING WHY YOU BUILT THIS]

[ANOTHER PARAGRAPH DESCRIBING YOUR IMPETUS FOR RELEASING THIS]

@ceeram
ceeram / auth.php
Created March 7, 2012 19:47
CakePHP Authentication and Authorization
No AuthComponent => everything is public
With AuthComponent => everything denied by default (except login action)
- open up certain action for public with: Auth->allow('action');
- open up all actions: Auth->allow();
- open up all non-admin actions, see Example (beforeFilter)
AuthComponent setup with Authorize object => restrict actions for authenticated users
- for instance with ControllerAuthorize, you define isAuthorized() function in your (App)Controller and
have it return true/false based on some conditions, See Example (isAuthorized)
@ceeram
ceeram / .travis.yml
Created March 14, 2012 19:02
Travis configuration file for CakePHP, add to the root of the repo.
language: php
php:
- 5.3
- 5.4
env:
- DB=mysql
- DB=pgsql
- DB=sqlite
@ceeram
ceeram / Odbc.php
Created July 6, 2012 21:05
Odbc datasource CakePHP for Throughbred odbc connection. UNSTABLE
<?php
/**
* ODBC for DBO
*
* PHP versions 4 and 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
@ceeram
ceeram / ModelSaveAllTest.php
Created October 2, 2012 23:20
ModelSaveAllTest.php
<?php
/**
* ModelWriteTest file
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
@ceeram
ceeram / gist:3852324
Last active October 11, 2015 11:28
cakephp submodule
cd to app
git submodule add git://github.com/ceeram/cakephp.git Core
<optional>
cd Core
git checkout 2.4
cd ..
</optional>
//update webroot/index.php:
@ceeram
ceeram / trait.php
Created November 17, 2012 17:53 — forked from lorenzo/trait.php
trait foo { function bob() { echo 'from trait'; }}
class bar { use foo { bob as likeBob }; function bob() { $this->likeBob();}}
class baz extends bar { function bob() { parent::bob(); echo ' from child'; }}
$a = new baz;
$a->bob();
//result: from trait from child
@ceeram
ceeram / gist:5060990
Last active December 14, 2015 08:49
dataProvider outside test class
<?php
/**
* Provider Test Case
*
*/
class ProviderTest extends PHPUnit_Framework_TestCase {
/**
*