PHPackages                             pieceofcake2/app - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. pieceofcake2/app

ActiveProject[Framework](/categories/framework)

pieceofcake2/app
================

CakePHP 2 Application skeleton

v2.3.0(7mo ago)24.3k120MITPHPPHP &gt;=8.0CI passing

Since Oct 3Pushed 6mo agoCompare

[ Source](https://github.com/pieceofcake2/app)[ Packagist](https://packagist.org/packages/pieceofcake2/app)[ RSS](/packages/pieceofcake2-app/feed)WikiDiscussions 2.x Synced 1mo ago

READMEChangelogDependencies (5)Versions (5)Used By (20)

CakePHP 2.x Application Skeleton
================================

[](#cakephp-2x-application-skeleton)

[![GitHub License](https://camo.githubusercontent.com/8e9a1b61eb4836cebf37e051b86396d9db9b8909def1cbdeef55ece3747746d4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f70696563656f6663616b65322f6170703f6c6162656c3d4c6963656e7365)](LICENSE)[![Packagist Version](https://camo.githubusercontent.com/03898ae04c58806b1edbcb9e567494294d957f64757cd322ad05c5a50cc894f4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70696563656f6663616b65322f6170703f6c6162656c3d5061636b6167697374)](https://packagist.org/packages/pieceofcake2/app)[![PHP](https://camo.githubusercontent.com/4a4785f9363abbda163a5253ce1d46fb2c5e58da67e9bc0046ae996ecae1f6ff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f70696563656f6663616b65322f6170702f7068703f6c6f676f3d706870266c6f676f436f6c6f723d253233464646464646266c6162656c3d504850266c6162656c436f6c6f723d25323337373742423426636f6c6f723d253233464646464646)](https://camo.githubusercontent.com/4a4785f9363abbda163a5253ce1d46fb2c5e58da67e9bc0046ae996ecae1f6ff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f70696563656f6663616b65322f6170702f7068703f6c6f676f3d706870266c6f676f436f6c6f723d253233464646464646266c6162656c3d504850266c6162656c436f6c6f723d25323337373742423426636f6c6f723d253233464646464646)[![CakePHP](https://camo.githubusercontent.com/1f92b8018a1ec9b7c6a2d2a7a05097d012981d56f4bfa34ed7c182423b10956d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f70696563656f6663616b65322f6170702f70696563656f6663616b65322f63616b657068703f6c6f676f3d63616b65706870266c6f676f436f6c6f723d253233464646464646266c6162656c3d43616b65504850266c6162656c436f6c6f723d25323344333343343326636f6c6f723d253233464646464646)](https://camo.githubusercontent.com/1f92b8018a1ec9b7c6a2d2a7a05097d012981d56f4bfa34ed7c182423b10956d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f70696563656f6663616b65322f6170702f70696563656f6663616b65322f63616b657068703f6c6f676f3d63616b65706870266c6f676f436f6c6f723d253233464646464646266c6162656c3d43616b65504850266c6162656c436f6c6f723d25323344333343343326636f6c6f723d253233464646464646)

A reference implementation for CakePHP 2.x applications using a modern, CakePHP 5.x-compatible directory structure.

Warning

**CakePHP 2.x is for legacy maintenance only.**For new projects, use [CakePHP 5.x](https://cakephp.org/) instead.

Planning to migrate to CakePHP 5.x?
-----------------------------------

[](#planning-to-migrate-to-cakephp-5x)

If you're planning to upgrade to CakePHP 5.x in the future, you can **prepare now** by adopting the modern directory structure while still on CakePHP 2.x:

**Traditional migration approach (harder):**

```
CakePHP 2.x → CakePHP 5.x
(change everything at once: code + folder structure + APIs)

```

**New gradual migration approach (easier):**

```
Step 1: CakePHP 2.x with traditional structure
        ↓ (modernize folder structure only)
Step 2: CakePHP 2.x with CakePHP 5.x-style structure ← You can stop here
        ↓ (upgrade code only)
Step 3: CakePHP 5.x with CakePHP 5.x-style structure

```

**Benefits:**

- ✅ **Smaller, manageable changes**: Separate folder restructuring from code changes
- ✅ **Test incrementally**: Verify each step works before moving to the next
- ✅ **Reduced risk**: You can stay on Step 2 indefinitely if needed
- ✅ **Team-friendly**: Easier for teams to understand and review smaller changes

Restructuring to Modern Layout (Step 2)
---------------------------------------

[](#restructuring-to-modern-layout-step-2)

This skeleton shows you how to achieve **Step 2** - running CakePHP 2.x with a modern folder structure.

### Directory Structure Comparison

[](#directory-structure-comparison)

**Before: Traditional CakePHP 2.x**

```
your-project/
├── app/
│   ├── Config/          (uppercase, nested)
│   ├── Controller/
│   ├── Model/
│   ├── View/           (templates + helpers mixed)
│   ├── Test/
│   ├── Plugin/
│   ├── Vendor/
│   └── tmp/
│       └── logs/
├── vendors/
└── ...

```

**After: Modern Structure (CakePHP 5.x Ready)**

```
your-project/
├── bin/
│   └── cake
├── config/             (lowercase, top-level)
├── src/                (all PHP code)
│   ├── Controller/
│   ├── Model/
│   └── View/           (Helper classes only)
├── templates/          (all .ctp files, separated)
├── resources/
│   └── locales/
├── tests/              (lowercase, top-level)
├── plugins/            (Composer-managed)
├── vendor/             (standard Composer)
├── logs/               (separated from tmp/)
├── tmp/
└── webroot/

```

### File Migration Map

[](#file-migration-map)

Use this table to migrate your files from traditional structure to modern structure:

From (Traditional)To (Modern)`app/Config/*``config/*``app/Controller/*``src/Controller/*``app/Model/*``src/Model/*``app/View/**/*.ctp``templates/**/*.ctp``app/View/Helper/*``src/View/Helper/*``app/Console/*``src/Console/*``app/Console/cake``bin/cake``app/Lib/*``src/Lib/*``app/Locale/*``resources/locales/*``app/Test/*``tests/*``app/Plugin/*``plugins/*` (use Composer)`app/Vendor/*``vendor/*` (use Composer)`app/tmp/logs/*``logs/*``app/tmp/*``tmp/*``app/webroot/*``webroot/*`### Migration Steps

[](#migration-steps)

#### 1. Update composer.json

[](#1-update-composerjson)

```
{
    "require": {
        "php": ">=8.0",
        "pieceofcake2/cakephp": "^2.12"
    },
    "autoload": {
        "classmap": ["src/"]
    },
    "config": {
        "vendor-dir": "vendor/",
        "sort-packages": true,
        "allow-plugins": {
            "composer/installers": true
        }
    },
    "extra": {
        "installer-paths": {
            "plugins/{$name}/": ["type:cakephp-plugin"]
        }
    }
}
```

#### 2. Update Bootstrap Path Definitions

[](#2-update-bootstrap-path-definitions)

Copy or reference this skeleton's `webroot/index.php`, `webroot/test.php`, and `bin/cake` to update the path definitions in your project:

```
define('ROOT', dirname(__DIR__));
define('APP_DIR', 'src');                     // Changed from 'app'
define('APP', ROOT . DS . APP_DIR . DS);
define('CONFIG', ROOT . DS . 'config' . DS);  // Top-level, lowercase
define('TESTS', ROOT . DS . 'tests' . DS);    // Top-level, lowercase
define('TMP', ROOT . DS . 'tmp' . DS);        // Top-level
define('LOGS', ROOT . DS . 'logs' . DS);      // Separated from tmp/
define('VENDORS', ROOT . DS . 'vendor' . DS); // Standard Composer
```

Refer to this skeleton's implementation files for complete examples.

#### 3. Migrate Files

[](#3-migrate-files)

Move files according to the File Migration Map above. You can do this gradually:

1. Configuration files: `app/Config/*` → `config/*`
2. PHP code: `app/Controller/*`, `app/Model/*` → `src/`
3. Templates: `app/View/**/*.ctp` → `templates/`
4. Tests: `app/Test/*` → `tests/`
5. Dependencies: Use Composer for plugins and vendors

#### 4. Verify Your Application Still Works

[](#4-verify-your-application-still-works)

The [pieceofcake2/cakephp](https://github.com/pieceofcake2/cakephp) core automatically supports this modern structure with `App::uses()` and class loading, so your existing CakePHP 2.x code should work without modifications.

#### 5. Leverage Composer Autoloading (Optional)

[](#5-leverage-composer-autoloading-optional)

Once Composer's autoload is configured in `composer.json`, you can remove `App::uses()` calls from your code:

```
"autoload": {
    "classmap": ["src/"]
}
```

After running `composer dump-autoload`, you can safely remove `App::uses()` statements from your controllers, models, helpers, and shells.

Important

You must run `composer dump-autoload` every time you create a new class file. Composer's classmap autoloader needs to be regenerated to recognize new classes.

For example:

```
// Before
App::uses('AppController', 'Controller');

class UsersController extends AppController {
    // ...
}

// After (with Composer autoload)
class UsersController extends AppController {
    // ...
}
```

**Note:** Plugins that don't support Composer autoloading will still require `App::uses()` or `CakePlugin::load()` to function properly.

Upgrading to CakePHP 5.x (Step 3)
---------------------------------

[](#upgrading-to-cakephp-5x-step-3)

Once you've completed Step 2 (modern folder structure with CakePHP 2.x), upgrading to CakePHP 5.x becomes much simpler:

**What's already done:**

- ✅ Directory structure is already correct - No need to reorganize files
- ✅ Templates already separated - No need to move `.ctp` files
- ✅ Modern Composer setup - Already using `vendor/` and `plugins/`

**What you need to do:**

- Update `composer.json` to require CakePHP 5.x
- Update code for CakePHP 5.x API changes
- Test and fix compatibility issues

**The key advantage:** You can focus 100% on code changes, not structural changes.

Refer to the [CakePHP 5.x Migration Guide](https://book.cakephp.org/5/en/appendices/5-0-migration-guide.html) for framework-specific changes.

Requirements
------------

[](#requirements)

- PHP 8.0, 8.1, 8.2, 8.3, 8.4, 8.5
- Composer
- Database: MySQL 5.6+, PostgreSQL 9.4+, SQLite 3, or SQL Server 2022+
- PHP Extensions: `mbstring`, `intl`, `openssl`, PDO driver for your database

See [pieceofcake2/cakephp requirements](https://github.com/pieceofcake2/cakephp#requirements--compatibility) for details.

Technical Implementation
------------------------

[](#technical-implementation)

This modern directory structure works with CakePHP 2.x through custom path configuration in bootstrap files (`webroot/index.php`, `webroot/test.php`, `bin/cake`).

The [pieceofcake2/cakephp](https://github.com/pieceofcake2/cakephp) core has been enhanced to:

- Automatically load classes from `src/Controller/`, `src/Model/`, etc. with `App::uses()`
- Find templates in the `templates/` directory
- Support both modern and traditional file locations during migration

**You don't need to modify your application code** - the framework handles the path mapping automatically.

Development
-----------

[](#development)

### Running Tests

[](#running-tests)

```
./bin/cake test app AllTests
```

Or with PHPUnit:

```
./vendor/bin/phpunit
```

### Code Standards

[](#code-standards)

Check your code against CakePHP coding standards:

```
./vendor/bin/phpcs
```

Documentation
-------------

[](#documentation)

- [CakePHP 2.x Documentation](https://book.cakephp.org/2.0/en/)
- [CakePHP 5.x Migration Guide](https://book.cakephp.org/5/en/appendices/5-0-migration-guide.html)

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) file for details.

Support
-------

[](#support)

This is a community-maintained fork of CakePHP 2.x. For issues and questions:

- [pieceofcake2/cakephp Issues](https://github.com/pieceofcake2/cakephp/issues)
- [pieceofcake2/app Issues](https://github.com/pieceofcake2/app/issues)

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance64

Regular maintenance activity

Popularity21

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~4 days

Total

5

Last Release

209d ago

PHP version history (2 changes)v2.0.0PHP ^8.0

v2.2.0PHP &gt;=8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/578548?v=4)[TSURU](/maintainers/ttsuru)[@ttsuru](https://github.com/ttsuru)

---

Top Contributors

[![ttsuru](https://avatars.githubusercontent.com/u/578548?v=4)](https://github.com/ttsuru "ttsuru (23 commits)")[![dereuromark](https://avatars.githubusercontent.com/u/39854?v=4)](https://github.com/dereuromark "dereuromark (4 commits)")

---

Tags

cakephpSkeleton

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pieceofcake2-app/health.svg)

```
[![Health](https://phpackages.com/badges/pieceofcake2-app/health.svg)](https://phpackages.com/packages/pieceofcake2-app)
```

###  Alternatives

[composer/installers

A multi-framework Composer library installer

1.4k136.0M6.0k](/packages/composer-installers)[cakephp/debug_kit

CakePHP Debug Kit

86514.0M138](/packages/cakephp-debug-kit)[cakephp/utility

CakePHP Utility classes such as Inflector, String, Hash, and Security

12127.1M63](/packages/cakephp-utility)[friendsofcake/bootstrap-ui

Bootstrap front-end framework support for CakePHP

3492.1M32](/packages/friendsofcake-bootstrap-ui)[cakephp/database

Flexible and powerful Database abstraction library with a familiar PDO-like API

9824.6M33](/packages/cakephp-database)[cakephp/migrations

Database Migration plugin for CakePHP

13912.0M222](/packages/cakephp-migrations)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
