PHPackages                             multidimensional/cakephp-subdomains - 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. multidimensional/cakephp-subdomains

ActiveCakephp-plugin[Framework](/categories/framework)

multidimensional/cakephp-subdomains
===================================

Easily add sub domains to your CakePHP application using route prefixes.

v1.1.0(9y ago)36325MITPHPPHP &gt;=5.5.9

Since Jan 1Pushed 8y ago4 watchersCompare

[ Source](https://github.com/multidimension-al/cakephp-subdomains)[ Packagist](https://packagist.org/packages/multidimensional/cakephp-subdomains)[ Docs](https://github.com/multidimension-al/cakephp-subdomains)[ RSS](/packages/multidimensional-cakephp-subdomains/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (5)Dependencies (2)Versions (5)Used By (0)

CakePHP Subdomain Routing
=========================

[](#cakephp-subdomain-routing)

[![Build Status](https://camo.githubusercontent.com/f83f53ebbaeed04c3b70fbb44197e8c5eadd078b63e80ff07cb0301820ef6be8/68747470733a2f2f7472617669732d63692e6f72672f6d756c746964696d656e73696f6e2d616c2f63616b657068702d737562646f6d61696e732e737667)](https://travis-ci.org/multidimension-al/cakephp-subdomains)[![Latest Stable Version](https://camo.githubusercontent.com/49cc42256d8c094c4fc415feb424c5983a50da6d4ae8ad15918b6763c5460e38/68747470733a2f2f706f7365722e707567782e6f72672f6d756c746964696d656e73696f6e616c2f63616b657068702d737562646f6d61696e732f762f737461626c652e737667)](https://packagist.org/packages/multidimensional/cakephp-subdomains)[![Code Coverage](https://camo.githubusercontent.com/13962336bf4809ec53ea07de3099582767f574d3a0ebf95fb9d08656a9f8f090/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d756c746964696d656e73696f6e2d616c2f63616b657068702d737562646f6d61696e732f6261646765732f636f7665726167652e706e67)](https://scrutinizer-ci.com/g/multidimension-al/cakephp-subdomains/)[![Minimum PHP Version](https://camo.githubusercontent.com/dd6bad85ee03cf570f4cf82ab69a80396fdbf48050af932f8f23aa551b0d1e5a/687474703a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230352e352d3838393242462e737667)](https://php.net/)[![License](https://camo.githubusercontent.com/baa3806326e1bbd0d9321723f1769fb46eb5ea2f6828e743de79455e3b73e300/68747470733a2f2f706f7365722e707567782e6f72672f6d756c746964696d656e73696f6e616c2f63616b657068702d737562646f6d61696e732f6c6963656e73652e737667)](https://packagist.org/packages/multidimensional/cakephp-subdomains)[![Total Downloads](https://camo.githubusercontent.com/e23dd2a67455356396e30ae4940fd828186ccd1865bb05ffcedce368a40360ab/68747470733a2f2f706f7365722e707567782e6f72672f6d756c746964696d656e73696f6e616c2f63616b657068702d737562646f6d61696e732f642f746f74616c2e737667)](https://packagist.org/packages/multidimensional/cakephp-subdomains)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/dd991cc05fcdde0d309491d5d7a93d54f85dbb63c934988323a05cfd76e3c367/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d756c746964696d656e73696f6e2d616c2f63616b657068702d737562646f6d61696e732f6261646765732f7175616c6974792d73636f72652e706e67)](https://scrutinizer-ci.com/g/multidimension-al/cakephp-subdomains/)

Easily add sub domains to your CakePHP application using route prefixes. Based on [code](https://github.com/cakephp/cakephp/issues/7140) created by [chinpei215](https://github.com/chinpei215).

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

[](#requirements)

- CakePHP 3.3+
- PHP 5.5.9+

Installation
------------

[](#installation)

You can install this plugin into your CakePHP application using [composer](http://getcomposer.org).

The recommended way to install composer packages is:

```
composer require --prefer-dist multidimensional/cakephp-subdomains

```

Setup
-----

[](#setup)

Load the plugin by running following command in terminal:

```
bin/cake plugin load Multidimensional/Subdomains -b -r

```

Or by manually adding following line to your app's `config/bootstrap.php`:

```
Plugin::load('Multidimensional/Subdomains', ['bootstrap' => true, 'routes' => true]);
```

In order to get the most out of the HTML link generator in CakePHP, we recommend installing our custom Subdomain HTML helper into your master **AppView.php**.

```
// src/View/AppView.php
class AppView extends View
{
    public function initialize()
    {
        parent::initialize();
        $this->loadHelper('Html', [
            'className' => 'Multidimensional/Subdomains.SubdomainHtml'
        ]);
    }
}
```

Configuration
-------------

[](#configuration)

Run the installation script command in termainl:

```
bin/cake SubdomainsInstall

```

This command will allow you to automatically create a configuration file with the list of your subdomains for the plugin to use. You can also run this command to add or delete additional subdomains.

Alternatively, you can create a `config/subdomains.php` file in your main CakePHP config folder:

```
return [
    'Multidimensional/Subdomains' =>
        ['Subdomains' =>
            ['{SUBDOMAIN_1}', '{SUBDOMAIN_2}', /*...*/ '{SUBDOMAIN_N}']
        ]
    ];
```

Usage
-----

[](#usage)

The plugin will automatically add the subdomains you specify as CakePHP prefixes.

When generating links, include the subdomain prefix you want to use and the Router will automatically create the link using the subdomain URL.

```
//Link to http://admin.example.com/articles/
$this->Html->link(['prefix'=>'admin', 'controller'=>'Articles', 'action'=>'index']);
```

Advanced options when the custom HTML helper is installed.

```
//Link to http://example.com/articles/
$this->Html->link(['prefix'=>false, 'controller'=>'Articles', 'action'=>'index']);

//Link to http://www.example.com/articles/
$this->Html->link(['prefix'=>'www', 'controller'=>'Articles', 'action'=>'index']);
```

Note: The www prefix should be used sparingly. If you require the www to be prepended to your domain, we would recommend installing a middleware plugin that forces the www to be added to the domain. In any case, setting **'prefix' = false** is the best practice.

Contributing
------------

[](#contributing)

Please help our project by creating a fork, and sending a pull request.

We need help writing unit tests, implementing Travis-CI and generally improving the functionality of the code.

To Do
-----

[](#to-do)

- Travis CI and PHPUnit Testing

License
-------

[](#license)

```
The MIT License (MIT)

Copyright (c) 2016 multidimension.al

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 93.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 ~1 days

Total

4

Last Release

3415d ago

Major Versions

v0.0.1 → v1.0.02017-01-02

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6588235?v=4)[AJ Quick](/maintainers/ajquick)[@ajquick](https://github.com/ajquick)

---

Top Contributors

[![ajquick](https://avatars.githubusercontent.com/u/6588235?v=4)](https://github.com/ajquick "ajquick (150 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (11 commits)")

---

Tags

cakephpcakephp3subdomains

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/multidimensional-cakephp-subdomains/health.svg)

```
[![Health](https://phpackages.com/badges/multidimensional-cakephp-subdomains/health.svg)](https://phpackages.com/packages/multidimensional-cakephp-subdomains)
```

###  Alternatives

[cakephp/debug_kit

CakePHP Debug Kit

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

Bake plugin for CakePHP

11211.2M158](/packages/cakephp-bake)[friendsofcake/bootstrap-ui

Bootstrap front-end framework support for CakePHP

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

CakePHP Localized Plugin

218595.6k5](/packages/cakephp-localized)[cakephp/acl

Acl Plugin for CakePHP framework

109553.9k15](/packages/cakephp-acl)[cakephp/elastic-search

An Elastic Search datasource and data mapper for CakePHP

86766.6k8](/packages/cakephp-elastic-search)

PHPackages © 2026

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