almostengr/cakephp-core

Functionality for CakePHP applications

Maintainers

Package info

github.com/almostengr/cakephp-core

Type:cakephp-plugin

pkg:composer/almostengr/cakephp-core

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

2026.06.07 2026-06-07 23:24 UTC

This package is not auto-updated.

Last update: 2026-06-08 02:40:36 UTC


README

Table of Contents

Purpose

The purpose of this project is to reduce the coding time required for building CakePHP applications. While CakePHP does come with a default styling system, I have build with Bootstrap styling for several years. Thus wanting to use that same technology with CakePHP applications that I create.

Yes the FriendsOfCake/cakephp-bootstrap project does exist, it is not always kept up with the latest version of Bootstrap. Thus could be exposed to vulnerabilties or defects take longer to be fixed, which is not an ideal scenario.

System Requirements

  • CakePHP 5 or later
  • PHP 8.4 or later

Installation

To install, run the command

composer install almostengr/cakephp-bootstrap

Setup

Update Controllers

Add the below code to the AppController.php, so that it will apply to all the controllers in the application.

Alternatively, you can add the below to specific controllers so that the theme is only applied to views for that controller.

public function beforeRender(EventInterface $event): void
{
    parent::beforeRender($event);

    $this->viewBuilder()->setTheme('AlmostengrCakephpCore');
}

Controller Methods for Modals

Views that display content in modals, should have the below code at the end of the controller method:

$this->viewBuilder()->disableAutoLayout();

This code will disable the full layout from being displayed within the modal. It will only show the code that is in the defined view and Save Change and Cancel buttons.

Close After Modal Form Submit

In AppController.php, add the below method. This method should be called when there are no errors from submitting the modal forms.

public function noContent()
{
    return $this->response->withStatus(204)->withStringBody('');
}

This will return No Content 204 response to the client. When this is received, the page will refresh. Then when the form is submitted without errors, it will close the modal. Below is an example controller method.

public function add()
{
    $user = $this->Users->newEmptyEntity();
    if ($this->request->is('post')) {
        $user = $this->Users->patchEntity($user, $this->request->getData());
        if ($this->Users->save($user)) {
            return $this->response->withStatus(204)->withStringBody('');
        }
        $this->Flash->error(__('The user could not be saved. Please, try again.'));
    }
    $this->set(compact('user'));
    $this->viewBuilder()->disableAutoLayout();
}

Plugin List

Be sure that the below has been added to the array in the config/plugins.php file.

    'AlmostengrCakephpCore' => [],

Views

Modal Links

To open a modal using an anchor link, use the example below.

<a href="#" class="modalLink" data-href="/users/edit/<?= $user->id; ?>">Edit</a>
<a href="#" class="modalLink" data-href="/users/add">New User</a>

Custom Files

The below files are to be created. These files are to store customizations or additional functionlaity of the code. These files are not overwritten when plugin files are applied.

  • site.css in the /css directory
  • site.js in the /js directory

Configuration

Several configuration options can be entered to change the display of sections within the theme. These options should be added to the app_local.php file.

AlmostengrCakephpCore.container

When set to true, the container class will be added to the page to restrict the width of the content.

Default: true

AlmostengrCakephpCore.copyright

When set, this displays the name of who the copyright is associated with.

Default: RHT Services

AlmostengrCakephpCore.footer

Allows for the customization of the footer content.

Default: false

When set to true, create footer.php file and populate with the content that should be displayed in the footer of the page.

AlmostengrCakephpCore.googleAds

Enter the value for the ad campaign to display the ads on the website.

Default: ""

AlmostengrCakephpCore.googleAnalytics

Enter the value for the analytics campaign to gather analytics information from the website.

Default: ""

AlmostengrCakephpCore.menuItems

In the configuration file app_local.php, define the links that should appear in the navigation bar, like in the example below.

'AlmostengrCakephpCore' => [
    'menuItems' => [
        [
            'title' => 'Home',
            'url' => '/'
        ],
        [
            'title' => 'Raw Imports',
            'url' => ['controller' => 'CrimeMappingRaw', 'action' => 'index']
        ],
        [
            'title' => 'External Docs',
            'url' => 'https://rhtservices.net' // External raw string link
        ]
    ]
]

Default: []

AlmostengrCakephpCore.navName

This option sets the name of the application in the navigation bar.

Default: My Application

AlmostengrCakephpCore.sidebar

This option lets you set the location of the side bar.

Default: none

Options: none, left, right

When set to left or right, create sidebar.php file and populate with the content that should be displayed in the sidebar of the page.

AlmostengrTheme.siteName

This setting lets you define the name of the website that shows as the title of the website.

Default: My Application

Example Modal

Example modal code is located in element/modalContainerExample.php file.

Report Bugs and Feature Requests

To report a bug or request a feature be added, you may create a request on the project's Issue Queue.

License

This project is covered by GNU PUblic License. See LICENSE for more details.