CakePHP

CakePHP

CakePHP is an open-source web, rapid development framework for PHP that provides an extensible architecture for developing, maintaining, and deploying applications. It uses commonly known design patterns like MVC and ORM within the convention over configuration paradigm.

Cakephpvue-spa: A Basic CakePHP + VueJS Single Page Application

A Basic CakePHP + VueJS Single Page Application

A basic CakePHP + VueJS single page application. Provides basic skeleton/boilerplate to quickly get started with CakePHP and Vue.js.

Installation

Get project into your system

Via composer:

composer create-project ishanvyas22/cakephpvue-spa

Via cloning the project into your server:

git clone git@github.com:ishanvyas22/cakephpvue-spa.git

Install composer dependencies

composer install

Connect with your database

Run the migrations

bin/cake migrations migrate

Start CakePHP web server or create v-host to run this app.

Development

  1. Install npm packages
npm install
  1. Run below command (Uses awesome Asset Mix plugin for asset compilation)
    • To watch every changes in your vue file
npm run watch
  • To generate development version of js file
npm run dev
  • To generate production version of js file
npm run prod

Notes

  • This is project is under development currently so you might not want to use this app in production directly.
  • This is just a skeleton/example how you can implement the Vue.js with CakePHP.

Changelog

Please see CHANGELOG for more information about recent changes.

Contribution

I love to welcome your contributions if you know CakePHP / Vue.js.

Author: ishanvyas22
Source Code: https://github.com/ishanvyas22/cakephpvue-spa 
License: MIT license

#php #cakephp #vue #crud 

Cakephpvue-spa: A Basic CakePHP + VueJS Single Page Application

Xeta: A Resource to Help People Starting with @cakephp 3

Xeta : CakePHP 3 Resource

Xeta is a resource to help people starting with Cake3.

Actually, I have developed this blog to try CakePHP 3 and for my needs (personal blog), and I have decided to release it to help people with CakePHP 3, so there is probably some custom configurations/functions that only fit my needs.

Screenshots of the Administration Panel

Dashboard

Dashboard

Blog Articles Management

Blog Articles Management

Blog Articles Management

Users Management

Users Management

Demo

https://xeta.io

Install

If you need to install to try a function or any other things, just follow the steps bellow.

Requirements

Steps to install :

  • Setup a new database on your server
  • Run :
composer create-project --prefer-dist xety/xeta <application_name>
composer run-script installation

You need to download the browscap.ini file.

vendor/bin/browscap-php browscap:fetch
vendor/bin/browscap-php browscap:convert
  • Congratulations ! The application is ready to use. 👍

Pre-installed Accounts

  • Admin account
    • User : Admin | Pass : administrator
  • Member account
    • User : Test | Pass : testaccount

Documentation

https://github.com/XetaIO/Xeta/wiki

Features

This project implements many features and will implements more in the future. Here's a list of the features developed in Xeta :

Blog

  • Categories
  • Comments
  • Likes Articles
  • Article's Internationalization (You change your language, the article is also translated in the language that you have choosen)
  • Archives
  • Quote
  • Attachments

Admin Panel

  • Google Analytics integrated
  • Members Management
  • Blog Management
    • Attachments
    • Categories
    • Articles
  • Groups Management
  • Settings Management

Private Conversations

  • Multi-Participants
  • Kick/Invite Participants
  • Star Conversations

Two Factor Authentication (TOTP)

Logs

Preview Logs Preview

Logs Events list :

CommandDescription
user.connection.manual.successTriggered when the user login on the login page.
user.connection.manual.failedTriggered when the user failed to login on the login page.
user.connection.autoTriggered when the user is automated login with Cookies.
user.account.modifyTriggered when the user has modified his account.
user.emailTriggered when the user has changed his Email.
user.password.changeTriggered when the user has changed his password.
user.password.resetTriggered when the user has asked a password reset.
user.password.reset.successfulTriggered when an user has successfully reset his password with the Email.
2FA.enabledTriggered when an user enbale the 2FA mode.
2FA.disabledTriggered when an user disable the 2FA mode.
2FA.recovery_code.regenerateTriggered when an user regenerate a new recovery code.
2FA.recovery_code.usedTriggered when an user use his recovery code.

WYSIWYG Editor (CKEditor)

  • Articles, Comments

All the CakePHP3's features that i use in the project are described here.

Information

If you want to contribute to the project by adding new features or just fix a bug, feel free to do a PR.

Contribute

Follow this guide to contribute

Special Thanks

TravisCoverageScrutinizerStable VersionDownloadsLicense
Build StatusCoverage StatusScrutinizerLatest Stable VersionTotal DownloadsLicense

Author: XetaIO
Source Code: https://github.com/XetaIO/Xeta 
License: 

#php #cakephp #framework #dashboard 

Xeta: A Resource to Help People Starting with @cakephp 3

Cakephp3-examples: A Collection Of Examples for CakePHP 3

CakePHP 3 ORM Examples

A collection of examples showing the best of the CakePHP 3 ORM

The SQL schema

The SQL schema used for the examples can be found in the config/Schema/world.sql file.

Slides

The slides that got this repo started can be found in the slides.pdf file

Author: lorenzo
Source Code: https://github.com/lorenzo/cakephp3-examples 
License: 

#php #cakephp 

Cakephp3-examples: A Collection Of Examples for CakePHP 3

Cakephp Realworld Example App

Example CakePHP codebase containing real world examples (CRUD, auth, advanced patterns and more) that adheres to the RealWorld spec and API.

This repo is functionality complete — PRs and issues welcome!


Getting started

Installation

Clone the repository

git clone git@github.com:gothinkster/cakephp-realworld-example-app.git

Switch to the repo folder

cd cakephp-realworld-example-app

Install all the dependencies using composer

composer install

Configure your database settings in the config/app.php file(See: Datasource/default)

vi config/app.php

Run the database migrations (Set the database connection in app.php)

bin/cake migrations migrate

Start the local development server

bin/cake server

You can now access the server at http://localhost:8765

Database seeding

Populate the database with seed data with relationships which includes users, articles, comments, tags, favorites and follows. This can help you to quickly start testing the api or couple a frontend and start using it with ready content.

Run the database seeder and you're done

bin/cake migrations seed

API Specification

This application adheres to the api specifications set by the Thinkster team. This helps mix and match any backend with any other frontend without conflicts.

Full API Spec

For more information on how to this works with other frontends/backends, head over to the RealWorld repo.

How it works

Please check the official cakephp installation guide for server requirements before you start. Official Documentation


Code overview

Dependencies

Folders

  • src - Contains all the application logic.
  • config - Contains all the application configuration files.
  • src/Model/Entity - Contains all cakephp ORM entites.
  • src/Model/Table - Contains all cakephp ORM tables.
  • src/Service - Contains application services that represents root api endpoints.
  • src/Service/Action - Contains application endpoints logic logic.
  • src/Service/Renderer - Contains the final api response formatter.
  • /config/Migrations - Contains all the database migrations.

Environment configuration

  • config/app.php - Configuration settings can be set in this file

Note : You can quickly set the database information and other variables in this file and have the application fully working.


Testing API

Run the cakephp development server

bin/cake server

The api can now be accessed at

http://localhost:8765/api

Request headers

RequiredKeyValue
YesContent-Typeapplication/json
YesX-Requested-WithXMLHttpRequest
OptionalAuthorizationToken {JWT}

Refer the api specification for more info.


Authentication

This applications uses JSON Web Token (JWT) to handle authentication. The token is passed with each request using the Authorization header with Token scheme. The cakephp authenticate middleware configured for handling JWT authentication and validation and authentication of the token. Please check the following sources to learn more about JWT.


Cross-Origin Resource Sharing (CORS)

This applications has CORS enabled by default on all API endpoints. Please check the following sources to learn more about CORS.

Author: Gothinkster
Source Code: https://github.com/gothinkster/cakephp-realworld-example-app 
License: View license

#php #cakephp #app #restapi 

Cakephp Realworld Example App

A Sample CakePHP 3 Application Built with The Crud Plugin

CakePHP Application Example Using the Crud Plugin

This is an example applicaiton that implements the bookmarker tutorial form the CakePHP manual, but using the super powerful Crud plugin.

Installation

  1. Download Composer or update composer self-update.
  2. Run php composer.phar create-project --prefer-dist -s dev lorenzo/cakephp3-bookmarker [app_name].

Configuration

Read and edit config/app.php and setup the 'Datasources' and any other configuration relevant for your application.

Run migrations

After setting up the databse, load the tables

bin/cake migrations migrate

Author: lorenzo
Source Code: https://github.com/lorenzo/cakephp3-bookmarkr 
License: 

#php #cakephp #crud 

A Sample CakePHP 3 Application Built with The Crud Plugin

BlogMVC-CakePHP3: A Simple CakePHP 3 App to See How CakePHP 3 Works!

CakePHP 3 - BlogMVC

A simple CakePHP 3 application to see how CakePHP 3 works !

Installation

  1. Download Composer or update composer self-update.
  2. Run composer install.
  3. Edit config/app.php with your databases informations (Search "Datasources")
  4. RunYou can now either use your machine's webserver to view the default home page, or start up the built-in webserver with:
bin/cake server -p 8765

Then visit http://localhost:8765 to see the welcome page.

bin/cake migrations migrate
bin/cake migrations seed

Author: Kareylo
Source Code: https://github.com/Kareylo/BlogMVC-CakePHP3 
License: 

#php #cakephp #blog #mvc 

BlogMVC-CakePHP3: A Simple CakePHP 3 App to See How CakePHP 3 Works!

Quickapps/cms: Modular CMS Powered By CakePHP

QuickAppsCMS

Free open source content management system for PHP, released under GPL License and powered by CakePHP 3.0 MVC framework.

This is an unstable repository and should be treated as an alpha.

Requirements

  • Apache with mod_rewrite
  • PHP 5.5.9 or higher
  • mbstring extension installed
  • mcrypt extension installed
  • intl extension installed
  • fileinfo extension installed
  • PHP safe mode disabled
  • Supported database storage engines:
    • MySQL (5.1.10 or greater)
    • PostgreSQL
    • Microsoft SQL Server (2008 or higher)
    • SQLite 3
  • Write permission in your server

Installing QuickAppsCMS

You must install QuickAppsCMS using composer. QuickAppsCMS is designed to run as a stand alone application, so you must use the website skeleton as starting point:

  1. Download Composer or update composer self-update.
  2. Run php composer.phar create-project -s dev quickapps/website [your_website_name].

If Composer is installed globally, run:

composer create-project -s dev quickapps/website [website_name]

After composer is done visit http://example.com/ and start QuickAppsCMS installation.

Links of Interest

Author: Quickapps
Source Code: https://github.com/quickapps/cms 
License: GPL-3.0 license

#php #cakephp #cms #bootstrap #jquery 

Quickapps/cms: Modular CMS Powered By CakePHP

CakeBlog: A blogging software written in CakePHP

CakeBlog

CakeBlog is an open source blogging software. Written by George Whitcher in PHP with the CakePHP framework. CakeBlog like CakePHP requires Composer and PHP 5.6+.

Installation

  1. Download and copy contents to your root folder.
  2. Install Composer.
  3. Run composer update to install CakePHP.
  4. Rename and configure the following files in your /config/ directory. app.default.php to app.php, cakeblog-config.default.php to cakeblog-config.php, cakeblog-functions.default.php to cakeblog-functions.php, and routes.default.php to routes.php
  5. Create MySQL database and user and enter information in your app.php.
  6. Run migrations by running bin/cake migrations migrate.
  7. Mark the migration completed by running bin/cake migrations mark_migrated
  8. You are now setup! A default user admin and password admin is created by default. Please login by visiting http://domain.com/admin and change this immediately.

Updating CakeBlog

  1. Login to your CakeBlog administration.
  2. Go to Update on the menu and download the files automatically from the latest GIT repository.
  3. Open terminal and run bin/cake migrations migrate. It is also suggested you update your CakePHP installation as well composer update.

NOTE: It is important NOT to make changes to the core CakeBlog files as they will be overwritten when updated.

Get Support!

Issues - Got issues? Please tell me! CakeBlog - CakeBlog Homepage.

Author: gwhitcher
Source Code: https://github.com/gwhitcher/CakeBlog 
License: 

#php #cakephp #blogging 

CakeBlog: A blogging software written in CakePHP

Skie/PhpStorm: PhpStorm Command Line Comands Generation Plugin

PhpStorm plugin for CakePHP 3.x

Installation

You can install this plugin into your CakePHP 3.x application using composer.

The recommended way to install composer packages is:

composer require skie/cakephp-phpstorm

After install plugin run

bin/cake CommandLine 

to generate the custom xml file for PhpStorm Command Line Tools.

File stored into .idea/commandlinetools/Custom_ck.xml After that you should restart PhpStorm. After restart all shell comands should be available from command line tool (Ctrl+Shift+X) with detailed help.

Usage example

Sample

Author: Skie
Source Code: https://github.com/skie/PhpStorm 
License: 

#php #cakephp #phpstorm 

Skie/PhpStorm: PhpStorm Command Line Comands Generation Plugin

CakeDC/oven: Setup Your Favorite Framework with 1 File and 1 Click

Setup your favourite framework with 1 file and 1 click!

IMPORTANT: This is not a deployment script, it's aimed to help developers installing CakePHP for the first time and get a working development environment up and running in seconds. Production environments should consider several other factors, like file permissions, virtualhost configuration, etc.

  • Upload oven.php file to your host/server
  • Access oven.php on your host via your favourite browser such as http://localhost/oven.php
  • Click the big oven knob in the middle of the page
  • CakePHP will auto install and ready to go

Requirements

  • PHP 5.5.9+

Support

For bugs and feature requests, please use the issues section of this repository.

Commercial support is also available, contact us for more information.

Contributing

This repository follows the CakeDC Plugin Standard. If you'd like to contribute new features, enhancements or bug fixes to the plugin, please read our Contribution Guidelines for detailed instructions.

Author: CakeDC
Source Code: https://github.com/CakeDC/oven 
License: View license

#php #cakephp 

CakeDC/oven: Setup Your Favorite Framework with 1 File and 1 Click

Cakephp3-netbeans: CakePHP3/4 support in NetBeans

NetBeans CakePHP3/4 Plugin

This plugin provides support for CakePHP3/4.

Requirements

  • NetBeans 12.0+

How To Install

Via NetBeans Plugin Portal Update Center

  • Tools > Plugins > Available Plugins
  • Click the "Check for Newest" button
  • Check "CakePHP3/4 Framework"
  • Click the "Install" button

Use downloaded nbms

  • Download a nbm (e.g. org-netbeans-modules-php-cake3-0.0.1-dev-201408251540.nbm)
  • Tools > Plugins > Downloaded > Add Plugins
  • Select the nbm
  • Click Install

How To Update

You can update to the new version by the same way as the install. You don't have to uninstall the old version.

How To Enable

  • Open the project properties dialog (Right-Click your project > properties)
  • Frameworks > CakePHP3/4 > Check Enabled

Use Your Custom Directory Structure

If you just installed Cake3/4 via Composer, you don't have to do anything.

  • Open the project properties
  • Set relative paths from your Source Directory to Path settings

Root

Use when your CakePHP app directory exists in your php project as a subdirectory.

e.g. set app to Root setting like the following case:

source directory
    ├── foo
    ├── bar
    └── app
            ├── README.md
            ├── bin
            ├── composer.json
            ├── composer.lock
            ├── config
            ├── index.php
            ├── logs
            ├── phpunit.xml.dist
            ├── plugins
            ├── src
            ├── tests
            ├── tmp
            ├── vendor
            └── webroot

The Others

The same as App settings of config/app.php

Templates, plugins, locales, e.t.c.

Support them using .cake file.

Features

  • Code completion
  • Smart Go To
  • Run Actions (Run Command)
  • Template files(Controller, Table, Helper, e.t.c.)
  • Support for a .cake file
  • Resolve mime-types for a ctp extension and a .cake file
  • Show a parent directory name of a ctp file in the multi-row tabs(see Tools > Options > Appearance > Document Tabs) e.g. home.ctp [Pages]
  • Custom nodes

Code Completion

Component

// in your Controller e.g. SomeController or AppController
public $components = ['Foo', 'My.Bar', 'Bar' => ['className' => 'MyBar'] ];

public initialize() {
    $this->loadComponent('Foo');
    $this->laodComponent('Bar', ['className' => 'MyBar']);
}

// in your Controller
$this->[Ctrl+Space]

Helper

// in your Controller e.g. SomeController or AppController
public $helpers = ['Foo', 'My.Bar', 'Bar' => ['className' => 'MyBar'] ];

// in your template file e.g. index.ctp
$this->[Ctrl+Space]

Table

// in your Controller e.g. SomeController 
$this->loadModel('Users');

// in your Controller
$this->[Ctrl+Space]

Please add @property to your table class if you want to use like the following:

// e.g. BookmarksTable
/**
 * @property \App\Model\Table\TagsTable $Tags 
 */
class BookmarksTable extends Table {
}

$this->Bookmarks->Tags->[Ctrl+Space]

Method Parameters

// e.g. path/to/your/template/index.ctp
// file path completion
$this->Html->css('[Ctrl+Space]');

// constants
$this->Html->docType('[Ctrl+Space]');

NOTE Please add a semicolon(;) if you want to use code completions for parameters. Tips: You can add it like the following: Ctrl+;

Smart Go To

This feature is not enabled by default. If you want to use it, please set the KeyMap to it. (Tools > Options > Keymap > Search CakePHP > CakePHP3/4: Smart Go To > e.g. set Ctrl + Shift + J)

Files related to the current editor are shown when you run this action. e.g. If your current file is a Controller, template, table, entity, testcase, conponent and helper file(s) will be shown.

You can change a list to specific category's one like the following. (Ctrl is a Ctrl or Command key)

  • Controller(All) : Ctrl + C (Ctrl + Shift + C)
  • Component : Ctrl + P (Ctrl + Shift + P)
  • Table : Ctrl + M (Ctrl + Shift + M)
  • Entity : Ctrl + E (Ctrl + Shift + E)
  • Behavior : Ctrl + B (Ctrl + Shift + B)
  • Templates : Ctrl + V (Ctrl + Shift + V)
  • View Cell : Ctrl + L (Ctrl + Shift + L)
  • Helper : Ctrl + H (Ctrl + Shift + H)
  • Fixture : Ctrl + F (Ctrl + Shift + F)
  • TestCase : Ctrl + T
  • Config : Ctrl + I or Ctrl + Shift + I

NOTE Core files are not shown (e.g. HtmlHelper, AuthComponent, e.t.c.)

Support for a .cake file

You can use the .cake if you want to use the specified directories for Controller, Table, Template, e.t.c.. The file format is the following:

{
    "cake": ".\/vendor\/cakephp\/cakephp",
    "build_path": {
        "entities": [
            ".\/src\/Model\/Entity\/"
        ],
        "tables": [
            ".\/src\/Model\/Table\/"
        ],
        "behaviors": [
            ".\/src\/Model\/Behavior\/"
        ],
        "controllers": [
            ".\/src\/Controller\/"
        ],
        "components": [
            ".\/src\/Controller\/Component\/"
        ],
        "templates": [
            ".\/src\/Template\/"
        ],
        "views": [
            ".\/src\/View\/"
        ],
        "helpers": [
            ".\/src\/View\/Helper\/"
        ],
        "consoles": [
            ".\/src\/Console\/"
        ],
        "shells": [
            ".\/src\/Shell\/"
        ],
        "tasks": [
            ".\/src\/Shell\/Task\/"
        ],
        "locales": [
            ".\/src\/Locale\/"
        ],
        "vendors": [
            ".\/vendor\/"
        ],
        "plugins": [
            ".\/plugins\/"
        ]
    }
}

NOTE It is not available in any categories.

Custom nodes

You can add some directories(nodes) under the your project tree. Controller, Model, e.t.c. are shown by default. If you want to hide/show them, please change the options.(Tools > Options > PHP > Frameworks and Tools > CakePHP3/4 > Custom nodes)

Actions

Right-click a project > CakePHP3/4

  • Run Command
  • Run server
  • Refresh

Run Command

All commands will be shown as a list in the command dialog. Then you can run a command with some parameters.

Run server

Just run cake server. If you want to set details, please use Run Configuration of project properties.

Refresh

Please run this action after you changed the .cake file or you updated the version of CakePHP. Refresh the version number and category paths.

Downloads

Issues

If you have issues, please submit them to GitHub Issues . Please don't create PRs soon.

Author: junichi11
Source Code: https://github.com/junichi11/cakephp3-netbeans 
License: Apache-2.0 license

#php #cakephp #plugin 

Cakephp3-netbeans: CakePHP3/4 support in NetBeans

Mixer: A Plugin to Discover and Manage CakePHP Plugins

Mixer

A plugin to discover and manage CakePHP plugins and generate skeleton application code.

Requirements

  • PHP 5.6+
  • CakePHP 3.4+

Installation

You can install this plugin into your CakePHP application using composer.

The recommended way to install composer packages is:

composer require --dev cakedc/mixer

Ensure Mixer Plugin is loaded in your config/bootstrap.php file

if (Configure::read('debug')) {
    Plugin::load('CakeDC/Mixer', ['bootstrap' => true, 'routes' => true]);
}

Now you can navigate to your app /mixer URL and start discovery and managing your plugins! It searches through all packages on Packagist with type "cakephp-plugin" excluding CakePHP 2.x packages.

Attention: we don't want you to use Mixer in production. That's why we're asking to add it to require-dev composer.json section and it will only work when debug is on.

Support

For bugs and feature requests, please use the issues section of this repository.

Commercial support is also available, contact us for more information.

Contributing

This repository follows the CakeDC Plugin Standard. If you'd like to contribute new features, enhancements or bug fixes to the plugin, please read our Contribution Guidelines for detailed instructions.

Author: CakeDC
Source Code: https://github.com/CakeDC/mixer 
License: View license

#php #cakephp #plugin 

Mixer: A Plugin to Discover and Manage CakePHP Plugins

Docker-cakephp: Example Dockerfile for Deploying A CakePHP Application

docker-cakephp

Dockerfile for deploying your CakePHP application in a Docker container, able to connect to a remote database with database-based sessions and inject ENV vars to configure your application.

Based on Ubuntu 16.04 Xenial and PHP 7.0

Note: This project is meant to be an example to study the basics and essentials of CakePHP in a Docker environment, therefore it is build on an Ubuntu base image rather then a PHP base image, uses a 'simple' webserver like Apache and has some non-efficient commands to demonstrate stuff.

Usage

You can edit the Dockerfile to add your own git, composer or custom commands to add your application code to the image.

To create the image myvendor/mycakephpapp, execute the following command on the docker-cakephp directory:

docker build -t myvendor/mycakephpapp .

Optional: You can now push your new image to a registry:

docker push myvendor/mycakephpapp

Running your CakePHP docker image

Start your image forwarding container port 80 to localhost port 80:

docker run -d -p 80:80 myvendor/mycakephpapp

Example: Connecting to a MySQL container

Start a MySQL container

docker run -d \
    --name mysql-server \
    -e MYSQL_ROOT_PASSWORD=sekret \
    -e MYSQL_DATABASE=cakephp \
    mysql:5.7

Start your image and:

  • Link it to the MySQL container you just started (so your container can contact it)
  • Connect to a remote database server using the CakePHP DATABASE_URL env variable filled with the variables given in the command above.
  • Use the database session handler using our the SESSION_DEFAULTS env variable (see Dockerfile for implementation)
docker run -d -p 80:80 \
    --name cakephp \
    -e "DATABASE_URL=mysql://root:sekret@mysql-server/cakephp?encoding=utf8&timezone=UTC&cacheMetadata=true" \
    -e "SESSION_DEFAULTS=database" \
    --link mysql-server:mysql \
    myvendor/mycakephpapp

Test your deployment

Visit http://localhost/ in your browser or

curl http://localhost/

You can now start using your CakePHP container!

Things to look out for

  • Think about handling session when running multiple containers behind a loadbalancer. You could modify the Dockerfile to sed the config/app.php file to use the database or cache session handler as implemented in the example.
  • If you want to store any files (e.g. uploads), please remember containers are 'stateless' and the data will be gone when you delete them. You can use volumes or an object storage with a webservice interface like Amazon S3.

Author: Stefanvangastel
Source Code: https://github.com/stefanvangastel/docker-cakephp 
License: MIT license

#php #cakephp #ubuntu #dockerfile 

Docker-cakephp: Example Dockerfile for Deploying A CakePHP Application

Cakephp-vagrant-setup: CakePHP 3 Vagrant Setup Made Simple

Vagrant Setup for CakePHP 3.x

This will generate the config files needed to get your vagrant environment setup for cakePHP running on Ubuntu 20.04 with PHP 7.4 on nginx.

Prerequisites

  • Virtualbox >= 6.1
  • Vagrant >= 2.2.10
  • Git
  • Root access to your local machine

Running the generator

To run the generator use the following command:

curl -sS https://raw.githubusercontent.com/cpierce/cakephp-vagrant-setup/master/scripts/vagrant_setup.php | php -- --ip 192.168.33.77 --hostname dev.cpierce.org

After the Vagrant file is created you can simply use the vagrant up command to start provisioning your local environment!

This will install the Vagrantfile you'll need. All available options are listed in the table below.

OptionDescriptionExample
ipIP Address for your virtual machine to use.--ip 192.168.33.77
hostnameHostname to use for virtual environment.--hostname dev.cpierce.org
memory-limitAmount of memory in MB virtual environment should consume when running.--memory-limit 1024
cpu-limitNumber of virtual CPUs to give virtual environment.--cpu-limit 1
skip-hostSkip the echo of the hostfile information if you don't want to do the sudo tee -a /etc/hosts part or do the host setup manually.--skip-host

Note: While you can have multiple hosts with the same IP Address, you cannot run them at the same time so it is always recommended to change the host IP Address for each configuration you setup. Note: Also thanks to Google making .dev (TLD) a require https on the HSTS you'll now have to either use another tld that isn't real or just do what I've been doing and update the dns for your domain such as dev.cpierce.org. One benefit of this is that you don't have to make changes to your host file and multiple people can use the same dev hostname. If you don't know how to do this you are welcome to use the default http://dev.cpierce.org/ to develop with.

Author: cpierce
Source Code: https://github.com/cpierce/cakephp-vagrant-setup 
License: MIT license

#php #cakephp #setup 

Cakephp-vagrant-setup: CakePHP 3 Vagrant Setup Made Simple

Cakephp-docker: A Cakephp 4 Template for Docker and Kubernetes

🍰 CakePHP Docker

A cakephp/app template for Docker Compose and Kubernetes. You might also be interested in CakePHP Galley which is similar to Laravel Sail or DevilBox.

Dependencies:

ServiceHost:PortDocker HostImage
PHP8.0-FPM w/ Xdebug 3-phpcnizzardini/php-fpm-alpine:8.0-latest
NGINX 1.19localhost:8080webnginx:1.19-alpine
MySQL 8localhost:3607dblibrary/mysql:8

Installation

Fork and clone this repository then run:

make init

That's it! Now just remove app/* from .gitignore. You may also want to remove .assets and adjust defaults in .github, .docker, and .kube.

Note: make init and make init.nocache output interactively, while make start and make up do not.

Mac Notes

Change your SHELL in the Makefile to /bin/zsh. This improves various output from the Makefile such as emoji's.

Mac ships with an older version of sed so install gnu-sed for some targets in the Makefile:

brew install gnu-sed

Then update sed to gsed in the Makefile.

Usage

After install browse to http://localhost:8080 to see the CakePHP welcome page.

A Makefile is provided with some optional commands for your convenience. Please review the Makefile as these commands are not exact aliases of docker-compose commands.

Make CommandDescription
makeShows all make target commands
make initRuns docker build, docker-compose up, and copies over env files
make init.nocacheSame as make.init but builds with --no-cache
make startStarts services docker-compose -f .docker/docker-compose.yml start
make stopStops services docker-compose -f .docker/docker-compose.yml stop
make upCreate and start containers docker-compose -f .docker/docker-compose.yml up -d
make downTake down and remove all containers docker-compose -f .docker/docker-compose.yml down
make restartRestarts services docker-compose -f .docker/docker-compose.yml restart
make php.shPHP terminal docker exec -it --user cakephp <PHP_CONTAINER> sh
make php.restartRestarts the PHP container
make db.shDB terminal docker exec -it <DB_CONTAINER> sh
make db.mysqlMySQL terminal mysql -u root -h 0.0.0.0 -p --port 3307
make web.shWeb terminal docker exec -it <WEB_CONTAINER> sh
make xdebug.onRestarts PHP container with xdebug.mode set to debug,coverage
make xdebug.offRestarts PHP container with xdebug.mode set to off
make composer.installdocker exec <PHP_CONTAINER> composer install --no-interaction
make composer.testdocker exec <PHP_CONTAINER> composer test
make composer.checkdocker exec <PHP_CONTAINER> composer check

PHP

See .docker/README.md for details.

Shell:

make php.sh

Helper commands:

make composer.install
make composer.test
make composer.check

MySQL

See .docker/README.md for details.

Shell:

make db.sh

MySQL shell (requires mysql client on your localhost):

make db.mysql

NGINX

See .docker/README.md for details.

Shell:

make web.sh

Xdebug

Xdebug is disabled by default. To toggle:

make xdebug.on
make xdebug.off

PHPStorm + Xdebug

Xdebug 3's default port is 9003.

Go to File > Settings > Languages & Frameworks > PHP > Servers

  • Name: localhost
  • Host: localhost
  • Port: 8080
  • Debugger: Xdebug
  • Use path mappings: Enable

Map your project's app directory to the absolute path on the docker container /srv/app

Reinstall

To completely reinstall delete existing containers and images, then remove the app/ directory and run make init again.

Author: Cnizzardini
Source Code: https://github.com/cnizzardini/cakephp-docker 
License: MIT license

#php #cakephp #docker #kubernetes 

Cakephp-docker: A Cakephp 4 Template for Docker and Kubernetes