Giter Club home page Giter Club logo

docker-ci4-php8.1's Introduction

CodeIgniter 4 on Apache with PHP 7.4

Instructions for building and using codeignter 4 in docker for development.

Extensions

An extension can be part of the base php container but not enabled by default. An extension can also be built with pecl install or docker-php-ext-install. To enable an extension you can use a2enmod or docker-php-ext-enable with the later form being perfered.

Building

docker build . -t nrb/php7.4-apache

Customizations

The www-data user has been changed from 33 to 1000 to take advantage of this fact the container should have the following environment variables:

    environment:
      - APACHE_RUN_USER="#1000"
      - APACHE_RUN_GROUP="#1000"

The default data directory has been set to /var/www/public

To fully take advatage this setup:

  • Makes sure Apache runs as user/group 1000
  • Makes sure container runs as user/group 1000
  • CodeIgntier is installed into /var/www with /var/www/public being exposed.

CodeIgniter Routing

Since Code Igniter 4.2 Auto Routing (Legacy)Auto Routing (Legacy) has been disabled. There is only one route defined / routes to Home::index. There are three options:

Standard Routing Rules expect a verb and URI as well as a target controller:

// Calls $Users->list()
$routes->get('users', 'Users::list');

Or can handle multiple verbs:

$routes->match(['get', 'put'], 'products', 'Product::feature');

How To Setup a New Container

# install CodeIgniter4
docker-compose run ci4 composer create-project codeigniter4/appstarter app
# chanege ./ to ./app/
sed -i "s/- .\/:\/var\/www/- .\/app:\/var\/www/g" docker-compose.yml

# set ci4 environment for testing
sed -z "s/# app.baseURL = ''/app.baseURL = 'https:\/\/example.com'/2" app/env > app/.env
sed -i "s/# CI_ENVIRONMENT = production/CI_ENVIRONMENT = development/g" app/.env

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.