close

Welcome Guest, Not a member yet? Register   Sign In
  CLI Command Routing
Posted by: Chroma - 04-20-2026, 06:33 AM - Replies (13)
Image

Hi,

I am currently trying to put some CLI commands into a different folder than the standard app/Controllers folder.

I want to put it into app/Modules/Mod1/Controller

The putting the test CLI code into the folder is straightforward and all works fine in the main app/Controllers folder. But in my Modules folder, I cannot find the right set of paths to make it run.

I have put my Mod1 into the autoload.php as with the other modules. They all run fine.

So, what do I need to type on the command line to make the test code run.

PHP Code:
    public $psr4 = [
    APP_NAMESPACE => APPPATH// For custom app namespace
    'Config'    => APPPATH 'Config',
    "Mod1"      => APPPATH 'Modules/Mod1',
    ]; 


PHP Code:
namespace Mod1\Controllers;

use 
CodeIgniter\Controller;

class 
Tester extends Controller
{

    public function cliMessage($to 'World')
    {
        return "Hello {$to}!" PHP_EOL;
    // end of function
// end of class 


To be clear, I am using the new routing system.

Your help is appreciated.


  Session problem from a Filter
Posted by: geirarnesen - 04-20-2026, 05:22 AM - Replies (2)
Image

I have an integration vs. Wordpress and set some data into the session. I am doing the operation in a Filter in the before function.
My implementation did before use the FileHandler for session which worked as a dream.
When switching to the DatabaseHandler, values being set to the session is not persisted and not available upon the next request.

Any reason why the set doesn't work from a Filter with the Databasehandler ?

Rgds Geir


Bug use url with underscore (_) in config Fatal error
Posted by: khao_lek - 04-20-2026, 04:19 AM - Replies (2)
Image

i'm config baseURL = " https://intranet_new.mysite.com:8080/report/public/ " on production ( CodeIgniter 4.7.2) .
and my application display : Fatal error: Uncaught CodeIgniter\Exceptions\ConfigException: Config\App::$baseURL "https://internet_new.mysite.com:8080/report/public/" is not a valid URL ...  #19 D:\www\report\system\Debug\Exceptions.php(117): service() #20 [internal function]: CodeIgniter\Debug\Exceptions->exceptionHandler() #21 {main} thrown in D:\www\report\system\HTTP\SiteURI.php on line 200
Thanks for help me.

Code:
app.baseURL = ' https://intranet_new.mysite.com:8080/report/public/'


  php-flasher.io adapter for CI4
Posted by: tassman - 04-19-2026, 11:08 PM - Replies (2)
Image

Can anyone with bigger mind see and write an adapter for flasher?
https://github.com/orgs/php-flasher/discussions/205
Its realy good tool.
Thx


  Over 400k files in the sessions folder
Posted by: geirarnesen - 04-18-2026, 01:59 AM - Replies (3)
Image

I discovered that I had over 400k ci_session files in the writeable/session folder.
The oldest files were back from February. I checked the Session.php which had
public int $expiration = 7200;

What is causing those old session files not to be deleted ?

Geir


  BUG: Inconsistent exception handling in testing environment
Posted by: giladsSG - 04-17-2026, 03:44 PM - Replies (2)
Image

Today, I have run into an issue with exception handling when testing. I was building an API and wanted to take advantage of the exception handler and use exceptions to drive responses and this worked perfectly in dev or production modes. but when I wrote tests for the api endpoints, these exceptions were not being handled by the handler I registered. On digging deeper, I found out that the error handler registered by ci4 was running instead of the exception handler. To be honest, I would not consider myself an exceptional developer, so I have no telling why the error handler was firing instead of the exception handler. Is this a BUG?(current version 4.7.2)
Here is the exception handler: 

PHP Code:
$this->request $request;
        $this->response $response;

        $accessDeniedMessage "You do not have permission to perform this action.";
        $message $exception->getMessage();
        $isVerbose in_array(ENVIRONMENT, ['development''testing']);

        if ($exception instanceof MfaRequiredException) {
            $response api_success($message$exception->getData(), 200);
        } elseif ($exception instanceof ValidationException) {
            $response api_error($message422, ['errors' => $exception->getErrors()]);
        } elseif ($exception instanceof AppException) {
            $response api_error($message$exception->getCode() ?: 400$exception->getData());
        } elseif ($exception instanceof AccessDeniedException) {
            $response api_error($accessDeniedMessage403);
        } else {
            $trackingId api_log_exception($exception);
            $data = [
                'tracking_id' => $trackingId
            
];
            if ($isVerbose) {
                $data['trace'] = $exception->getTrace();
            }

            $response api_error(
                $isVerbose $message 'An error occured. Please try again later.',
                500,
                $data
            
);
        }

        $response->send();

        exit($exitCode); 


  After calling software engineering 'dead,' Anthropic’s Claude Code creator Boris Cher
Posted by: InsiteFX - 04-17-2026, 01:13 PM - No Replies
Image

After calling software engineering 'dead,' Anthropic’s Claude Code creator Boris Cherny says coding tools like Microsoft VS Code, Apple Xcode, and others will be ‘dead soon’


  *.env file in different location
Posted by: petewulf1 - 04-14-2026, 09:39 AM - Replies (3)
Image

Hello guys,
It seems there is no official way to place the *.env file at a different location than the projects root folder. Why?
What would be an appropriate way to load from a different location without having to overwrite Boot.php?
Thanks!
Daniel


  feat(DI): Some dependency injection in CI
Posted by: patel-vansh - 04-14-2026, 04:45 AM - Replies (6)
Image

Hi everyone,
After working with CodeIgniter 4, I wanted to share some thoughts on Dependency Injection and CodeIgniter 4:
This is not a proposal to replace CI4’s simplicity or turn it into another framework. The goal would be to modernize dependency management in a way that still respects CI4’s philosophy: simple, predictable, explicit, and lightweight.

Why Discuss This?
The current Services pattern works well and is easy to understand, but it also has some limitations for larger or more modular applications:
- Uses a service locator pattern rather than constructor injection
- Manual dependency wiring increases as projects grow
For many apps this is not a problem. But for larger projects, cleaner dependency management can be valuable.

Suggested Direction
Introduce a small optional container that can coexist with the current system.
Example:
In the bootstrap process, you can inject any class:

PHP Code:
container()->bindUserRepositoryInterface::class, DatabaseUserRepository::class ); 
And just use it via constructor injection:
PHP Code:
class UserService {
    public function __construct( private readonly UserRepositoryInterface $repo ) {}

    public function getUser(int $userId) {
        return $this->repo->getUser($userId);
    }

Then, in controller:
PHP Code:
$service container()->get(UserService::class); 
This would automatically resolve dependencies recursively.

Example Binding Types
Class to class:
PHP Code:
container()->bind
    CacheInterface::class,
    FileCache::class
); 
Factory closure:
PHP Code:
container()->bind(UserService::class, function ($c) {
    return new UserService(
        $c->get(UserRepository::class),
        'foo'
    );
}); 
Useful when primitives/config values are needed.

Why This Could Benefit CI4
Better testability
Cleaner architecture for medium/large apps
Better package/module ecosystem
Modern PHP patterns while preserving CI4 simplicity
Gradual adoption with zero breakage

After some time, maybe, we can make the current service calls go through this container system, like this:
PHP Code:
function cache(bool $getShared true) {
    if ($getShared) {
        return container()->singleton(CacheInterface::class);
    }

    return container->get(CacheInterface::class);


  Boosting CI4 popularity
Posted by: enlivenapp - 04-13-2026, 08:50 AM - Replies (20)
Image

I've been a rabid supporter of CI since 1.7.2.  During the 'great lull' Codeigniter really took a hard hit with Laravel coming up and many devs jumping ship. I really want to do my part to help CI get back to the popularity it once had and (*gasp*) maybe rival Laravel.   

While I've been working on my CMS, I've found, what I feel, would be one of the best ways to implement such functionality similar to what Laraval offers. Their Service Providers solution to adding whatever package you want to use would be a massive advantage to Codeigniter.

The one argument I often hear/read is 'composer whatever' has this, just 'composer require' it and use it (usually coming across as kinda negative nancy since text has no real context).  I get that and it's 100% true, but that advice doesn't really cut it when CI is better than many frameworks in many ways but kinda can't get out of it's own way.  
  
As always, lively discussion is wanted, I'd really like to hear from the Foundation devs too.  Is there any interest from the Foundation to create a Service Provider/Packages and much expanded spark CLI kind of ecosystem for Codeigniter? 

Happy coding.


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Latest Threads
CLI Command Routing
by Chroma
4 hours ago
use url with underscore (...
by Chroma
Yesterday, 03:16 AM
I created the Igniter CMS...
by akassama
04-21-2026, 09:25 PM
php-flasher.io adapter fo...
by grimpirate
04-20-2026, 11:55 AM
Session problem from a Fi...
by geirarnesen
04-20-2026, 11:30 AM
Over 400k files in the se...
by ozornick
04-20-2026, 09:46 AM
Server Push/preloading?
by babainagBN
04-19-2026, 01:38 AM
BUG: Inconsistent excepti...
by ozornick
04-18-2026, 09:02 PM
After calling software en...
by InsiteFX
04-17-2026, 01:13 PM
feat(DI): Some dependency...
by TwistedAndy
04-16-2026, 09:47 AM

Forum Statistics
» Members: 209,460
» Latest member: raybetkim
» Forum threads: 78,683
» Forum posts: 380,918

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB