Giter Club home page Giter Club logo

codeigniter4-docker's Introduction

Hi there, I'm Antonio - aka atsanna 👋

Website

I am a husband, father and developer: I'll tell you a little about myself

  • I was born in Schorndorf in Germany, but my home is near Naples, Italy, even though my origins are on the island of Sardinia where I lived the first 30 years of my life.

  • I studied to be a surveyor, but in the end my passion for computer science is taking me on another path.

  • I worked for years as a teacher for a partner company of Autodesk, a large company that develops and distributes software for construction, mechanics and other design software ...

  • I currently work for a small IT company where I manage the infrastructure.

  • As for the world of information technology, I am totally self-taught: I am very curious and I always like to learn new things.

  • 2024 Objectives:

    • Contribute more to Open Source projects

Connect with me:

Codeigniter4.it | Website Antonio Sanna | LinkedIn Antonio Sanna | Facebook Antonio Sanna | Instagram


Languages and Tools:

Visual Studio Code HTML5 CSS3 JavaScript SQL MySQL MySQL Git GitHub Terminal



Recent GitHub Activity

  1. ❗️ Opened issue #21 in dirtsimple/poste.io
  2. ❌ Closed PR #7 in atsanna/Bonfire2
  3. ❌ Closed PR #8 in atsanna/Bonfire2
  4. ❌ Closed PR #12 in atsanna/Bonfire2
  5. 🗣 Commented on #43 in lonnieezell/Bonfire2

Top Langs

Top Langs


Thanksgiving

Thanks to codeSTACKr for making a video explaining how to build this page

codeigniter4-docker's People

Contributors

atsanna avatar fagnerdin avatar guxmartin avatar kenjis avatar kevinadhiguna avatar nicicalu avatar tansherjun-nixora avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codeigniter4-docker's Issues

Unable to connect to the database.

Hi, thank you for your work.
I created and started the containers on both a mac book pro and windows but codeigniter gives the error "Unable to connect to the database." while phpmyadmin container works fine.

in Database.php I tried both with 'hostname' => 'codeigniter4_mysql', and with 'hostname' => 'localhost'.

Can you help me?

Thank you

How do migration via spark

Premise

I did success connect to database via local server.
I understand basic of codeigniter4.
image

step1 docker-compose.yml

I'm changed port for codeigniter4_mysql because the port conflicts with the local MySQL.

version: "3"

services:
    #--------------------------------------------------------------------------#
    #--------------------------------------------------------------------------#
    #                     C O D E I G N I T E R  v4.1.4                        #
    #--------------------------------------------------------------------------#
    #--------------------------------------------------------------------------#
    codeigniter4:
        image: atsanna/codeigniter4:latest
        container_name: 'codeigniter4'
        ports:
            - 80:80
        links:
            - codeigniter4_mysql
        volumes:
            - ./localfolder/www:/var/www/html

    #--------------------------------------------------------------------------#
    #--------------------------------------------------------------------------#
    #                               M Y S Q L                                  #
    #--------------------------------------------------------------------------#
    #--------------------------------------------------------------------------#
    codeigniter4_mysql:
        image: mariadb:10.5.5
        container_name: 'codeigniter4_mysql'
        ports:
            - 3307:3306
        volumes:
            - ./localfolder/mysql:/var/lib/mysql
            - ./localfolder/logs/mysql:/var/log/mysql
        environment:
            MYSQL_ROOT_PASSWORD: rootpassword
            MYSQL_DATABASE: codeigniter4
            MYSQL_USER: codeigniter4
            MYSQL_PASSWORD: codeigniter4

    #--------------------------------------------------------------------------#
    #--------------------------------------------------------------------------#
    #                         P H P M Y A D M I N                              #
    #--------------------------------------------------------------------------#
    #--------------------------------------------------------------------------#
    codeigniter4_phpmyadmin:
        image: phpmyadmin/phpmyadmin:5.0.2
        container_name: 'codeigniter4_phpmyadmin'
        links:
            - codeigniter4_mysql
        environment:
            PMA_HOST: codeigniter4_mysql
            PMA_PORT: 3306
        ports:
            - 81:80
        volumes:
            - ./localfolder/sessions:/sessions

it's ok!
image

step2 connect to database

 // localfolder/www/codeigniter4/.env
 database.default.hostname = codeigniter4_mysql
 database.default.database = codeigniter4
 database.default.username = codeigniter4
 database.default.password = codeigniter4
 database.default.DBDriver = MySQLi

Some values ​​are in Japanese, but please focus to the numbers.

CREATE TABLE `users` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `user_id` INT UNSIGNED NOT NULL DEFAULT 0,
  `name` VARCHAR(32) NULL DEFAULT NULL,
  `age` INT UNSIGNED NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE INDEX `user_id` (`user_id`)
);

INSERT INTO `codeigniter4`.`users` (`user_id`, `name`, `age`) 
VALUES 
(100, '屋代駿介', 35),
(101, '須加友枝', 29),
(102, '永来一八', 15),
(103, '荷宮知愛', NULL);

create a entity

> php spark make:entity
  Entity class name: User
  File created: APPPATH\Entities\User.php

I append cast information.

    protected $casts   = [
        'id' => 'integer',
        'user_id' => 'integer',
        'age' => '?integer',
    ];

create a model.
no edit.

> php spark make:model
  Model class name: UserModel
  File created: APPPATH\Models\UserModel.php

step3 Editing Controller

it's simple

<?php

namespace App\Controllers;

use App\Models\UserModel;

class Home extends BaseController
{
    public function index($userId)
    {
        $userModel = new UserModel();
        $user = $userModel->where('user_id', $userId);
    
        d($user);
        d($user->id);
        d($user->user_id);
        d($user->name);
        d($user->age);
        
        return view('welcome_message');
    }
}

retrieve is failed. What may be the cause.
image

problem

What I'm curious about is that the connection information is null
image

I'm also worried that migrate cannot be executed. Please let me know if you can understand anything. thank you. :)

localfolder\www\codeigniter4> php spark migrate

CodeIgniter v4.1.4 Command Line Tool - Server Time: 2021-09-20 03:17:33 UTC-05:00

Running all new migrations...

[CodeIgniter\Database\Exceptions\DatabaseException]

Unable to connect to the database.
Main connection [MySQLi]: php_network_getaddresses: getaddrinfo failed: ̂悤ȃzXg͕słB

at SYSTEMPATH\Database\BaseConnection.php:400

Backtrace:
  1    SYSTEMPATH\Database\BaseConnection.php:570
       CodeIgniter\Database\BaseConnection()->initialize()

  2    SYSTEMPATH\Database\BaseConnection.php:1320
       CodeIgniter\Database\BaseConnection()->query('SHOW TABLES FROM `codeigniter4`')

  3    SYSTEMPATH\Database\BaseConnection.php:1351
       CodeIgniter\Database\BaseConnection()->listTables()

  4    SYSTEMPATH\Database\MigrationRunner.php:754
       CodeIgniter\Database\BaseConnection()->tableExists('migrations')

  5    SYSTEMPATH\Database\MigrationRunner.php:166
       CodeIgniter\Database\MigrationRunner()->ensureTable()

  6    SYSTEMPATH\Commands\Database\Migrate.php:84
       CodeIgniter\Database\MigrationRunner()->latest(null)

  7    SYSTEMPATH\CLI\Commands.php:63
       CodeIgniter\Commands\Database\Migrate()->run([])

  8    SYSTEMPATH\CLI\CommandRunner.php:70
       CodeIgniter\CLI\Commands()->run('migrate', [])

  9    SYSTEMPATH\CLI\CommandRunner.php:56
       CodeIgniter\CLI\CommandRunner()->index([])

 10    SYSTEMPATH\CodeIgniter.php:800
       CodeIgniter\CLI\CommandRunner()->_remap('index', 'migrate')

 11    SYSTEMPATH\CodeIgniter.php:399
       CodeIgniter\CodeIgniter()->runController(Object(CodeIgniter\CLI\CommandRunner))

 12    SYSTEMPATH\CodeIgniter.php:317
       CodeIgniter\CodeIgniter()->handleRequest(null, Object(Config\Cache), false)

 13    SYSTEMPATH\CLI\Console.php:48
       CodeIgniter\CodeIgniter()->run()

 14    ROOTPATH\spark:63
       CodeIgniter\CLI\Console()->run()

Build fail: missing asset/ecw/hexagon.zip

hexagon.zip contain ERDAS-ECW_JPEG_2000_SDK-5.5.0

File asset/ecw/hexagon.zip is 291.46 MB; this exceeds GitHub's file size limit of 100.00 MB

error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.

I am thinking of removing this component from the repository

database

hi atsanna, what is credentials from phpmyadmin and database ?

Cant change apache document root

Hi ! Congratulations on your project. I find it great. I am new to Docker and this solves many problems!
I would like to know how to change apache Documentroot to /var/ww/html
I tried many different ways and I can not get it changed I have always Codeigniter 4..1.1 starting at locahost.
I need to run different instances and diferent projects on localhost that's why I need to change it, but no way!
Can you please help me ?
Thank you and congratulatins again!
Paul

apache urlrewrite not working

Hi,
First of all, thank you very much for this docker image. It gets me on codeigniter4 on macbook in only a few hours.
I have 1 suggestion for improvement. Currently the mod rewrite is not enable the .htaccess does not work (at least in my installation). I needed to ssh into the docker and run "a2enmod rewrite" and restart the apache to get the rewrite working.
Maybe can add a line in Dockerfile:
RUN a2enmod rewrite

Just in case you are interested, I have also map apache.conf and startScript.sh to local directory.

Again, thank you for this project. Great job!

Apache2 not starting on container start?

Hello,

Thank you for creating this image ... it's great! I do have one issue ... Apache2 is not starting when I launch the container. I've been trying to dig for logs or any way to debug this, but I can't find anything. dmesg fails, etc.

Any ideas on why?

Each time I launch the container I have to issue a "service apache2 restart" and then everything is ok.

stopping application

Stopping Application wont stop.

$:~/codeigniter$ docker-compose down
Removing network codeigniter_default
WARNING: Network codeigniter_default not found.

I have to stop the container manually.

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.