Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions .php-cs-fixer.user-guide.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,11 @@
$config = require __DIR__ . '/.php-cs-fixer.dist.php';

$overrides = [
'echo_tag_syntax' => false,
'header_comment' => false,
'php_unit_internal_class' => false,
'no_unused_imports' => false,
'class_attributes_separation' => false,
'fully_qualified_strict_types' => [
'import_symbols' => false,
'leading_backslash_in_global_namespace' => true,
],
'echo_tag_syntax' => false,
'header_comment' => false,
'php_unit_internal_class' => false,
'no_unused_imports' => false,
'class_attributes_separation' => false,
];

return $config
Expand Down
5 changes: 3 additions & 2 deletions docs/cli/cli_commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ namespace App\Commands;

use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\CLI;
use CodeIgniter\CodeIgniter;

class AppInfo extends BaseCommand
{
Expand All @@ -90,7 +91,7 @@ class AppInfo extends BaseCommand
public function run(array $params)
{
CLI::write('PHP Version: ' . CLI::color(PHP_VERSION, 'yellow'));
CLI::write('CI Version: ' . CLI::color(\CodeIgniter\CodeIgniter::CI_VERSION, 'yellow'));
CLI::write('CI Version: ' . CLI::color(CodeIgniter::CI_VERSION, 'yellow'));
CLI::write('APPPATH: ' . CLI::color(APPPATH, 'yellow'));
CLI::write('SYSTEMPATH: ' . CLI::color(SYSTEMPATH, 'yellow'));
CLI::write('ROOTPATH: ' . CLI::color(ROOTPATH, 'yellow'));
Expand Down Expand Up @@ -146,7 +147,7 @@ A convenience method to maintain a consistent and clear error output to the CLI:

try {
// ...
} catch (\Exception $e) {
} catch (Exception $e) {
$this->showError($e);
}
```
Expand Down
20 changes: 12 additions & 8 deletions docs/cli/cli_signals.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,13 @@ Some operations should never be interrupted (database transactions, file operati
```php
<?php

namespace App\Commands;

use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\CLI;
use Exception;

class SampleCommand extends \BaseCommand
class SampleCommand extends BaseCommand
{
// ...
private function processOrder(array $orderData): void
Expand Down Expand Up @@ -231,7 +235,7 @@ class SampleCommand extends \BaseCommand
CLI::write('Transaction completed successfully', 'green');

return $orderId;
} catch (\Exception $e) {
} catch (Exception $e) {
// Rollback on error
$this->db->transRollback();

Expand Down Expand Up @@ -342,11 +346,11 @@ kill -CONT $PID # Resume - may lose terminal control

When you manually send `kill -CONT` from a different terminal:

**Expected behavior:**
**Expected behavior:**

- Process resumes and custom handlers execute

**Side effects:**
**Side effects:**

- Process loses foreground terminal control
- Ctrl+C and Ctrl+Z may stop working
Expand Down Expand Up @@ -463,7 +467,7 @@ This returns comprehensive information including:

#### registerSignals($signals = [SIGTERM, SIGINT, SIGHUP, SIGQUIT], $methodMap = [])

- **Parameters**
- **Parameters**
- **$signals** `array` List of signals to handle
- **$methodMap** `array` Optional signal-to-method mapping

Expand Down Expand Up @@ -576,7 +580,7 @@ Reset all states - useful for testing or restart scenarios.

#### withSignalsBlocked($operation)

- **Parameters**
- **Parameters**
- **$operation** `callable` The critical operation to execute without interruption

- **Returns**: The result of the operation
Expand All @@ -597,7 +601,7 @@ Check if signals are currently blocked.

#### mapSignal($signal, $method)

- **Parameters**
- **Parameters**
- **$signal** `int` Signal constant
- **$method** `string` Method name to call for this signal

Expand Down Expand Up @@ -642,7 +646,7 @@ class SampleCommand extends BaseCommand

#### getSignalName($signal)

- **Parameters**
- **Parameters**
- **$signal** `int` Signal constant

- **Returns**: Human-readable signal name
Expand Down
8 changes: 6 additions & 2 deletions docs/concepts/factories.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,12 @@ The first is `config()`, which returns an instance of a Config class. The only r
```php
<?php

use CodeIgniter\Config\Factories;

$appConfig = config('App');

// The code above is the same as the code below.
$appConfig = \CodeIgniter\Config\Factories::config('App');
$appConfig = Factories::config('App');
```

### model()
Expand All @@ -126,10 +128,12 @@ The second function, `model()`, returns an instance of a Model class. The only r
```php
<?php

use CodeIgniter\Config\Factories;

$user = model('UserModel');

// The code above is the same as the code below.
$user = \CodeIgniter\Config\Factories::models('UserModel');
$user = Factories::models('UserModel');
```

## Defining Classname to be Loaded
Expand Down
37 changes: 27 additions & 10 deletions docs/concepts/services.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ A quick example will probably make things clearer, so imagine that you need to p
```php
<?php

$timer = new \CodeIgniter\Debug\Timer();
use CodeIgniter\Debug\Timer;

$timer = new Timer();
```

And this works great, until you decide that you want to use a different timer class in its place. Maybe this one has some advanced reporting that the default timer does not provide. In order to do this, you now have to locate all of the places in your application where you have used the timer class. Since you might have left them in place to keep a performance log of your application constantly running, this might be a time-consuming and error-prone way to handle this. That's where services come in handy.
Expand All @@ -25,10 +27,12 @@ Instead of creating the instance ourselves, we let a central class create an ins
```php
<?php

use Config\Services;

$timer = service('timer');

// The code above is the same as the code below.
$timer = \Config\Services::timer();
$timer = Services::timer();
```

When you need to change the implementation used, you can modify the services configuration file, and the change happens automatically throughout your application without you having to do anything. Now you just need to take advantage of any new functionality and you're good to go. Very simple and error-resistant.
Expand Down Expand Up @@ -77,7 +81,9 @@ If you want to get a new instance of the Timer class, you need to pass `false` t
```php
<?php

$timer = \Config\Services::timer(false);
use Config\Services;

$timer = Services::timer(false);
```

### Convenience Functions
Expand All @@ -91,10 +97,12 @@ The first is `service()`, which provides access to the requested service. The on
```php
<?php

use Config\Services;

$logger = service('logger');

// The code above is the same as the code below.
$logger = \Config\Services::logger();
$logger = Services::logger();
```

!!! note "Note"
Expand All @@ -107,10 +115,12 @@ If the creation method requires additional parameters, they can be passed after
```php
<?php

use Config\Services;

$renderer = service('renderer', APPPATH . 'views/');

// The code above is the same as the code below.
$renderer = \Config\Services::renderer(APPPATH . 'views/');
$renderer = Services::renderer(APPPATH . 'views/');
```

#### single_service()
Expand All @@ -120,10 +130,12 @@ The second function, `single_service()`, works just like `service()` but returns
```php
<?php

use Config\Services;

$logger = single_service('logger');

// The code above is the same as the code below.
$logger = \Config\Services::logger(false);
$logger = Services::logger(false);
```

## Defining Services
Expand Down Expand Up @@ -152,6 +164,7 @@ Finally, add the `routes()` method to **app/Config/Services.php** to create a ne

namespace Config;

use App\Router\MyRouteCollection;
use CodeIgniter\Config\BaseService;

class Services extends BaseService
Expand All @@ -160,7 +173,7 @@ class Services extends BaseService

public static function routes()
{
return new \App\Router\MyRouteCollection(static::locator(), config('Modules'));
return new MyRouteCollection(static::locator(), config('Modules'));
}
}
```
Expand All @@ -177,14 +190,15 @@ A good example is the `renderer` service. By default, we want this class to be a
namespace Config;

use CodeIgniter\Config\BaseService;
use CodeIgniter\View\View;

class Services extends BaseService
{
// ...

public static function renderer($viewPath = APPPATH . 'views/')
{
return new \CodeIgniter\View\View($viewPath);
return new View($viewPath);
}
}
```
Expand All @@ -194,7 +208,9 @@ This sets the default path in the constructor method, but allows for easily chan
```php
<?php

$renderer = \Config\Services::renderer('/shared/views/');
use Config\Services;

$renderer = Services::renderer('/shared/views/');
```

### Shared Classes
Expand All @@ -206,6 +222,7 @@ There are occasions where you need to require that only a single instance of a s

namespace Config;

use App\Router\MyRouteCollection;
use CodeIgniter\Config\BaseService;

class Services extends BaseService
Expand All @@ -218,7 +235,7 @@ class Services extends BaseService
return static::getSharedInstance('routes');
}

return new \App\Router\MyRouteCollection(static::locator(), config('Modules'));
return new MyRouteCollection(static::locator(), config('Modules'));
}
}
```
Expand Down
3 changes: 2 additions & 1 deletion docs/database/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ An example to log all queries:

namespace Config;

use CodeIgniter\Database\Query;
use CodeIgniter\Events\Events;
use CodeIgniter\Exceptions\FrameworkException;
use CodeIgniter\HotReloader\HotReloader;
Expand All @@ -27,7 +28,7 @@ use CodeIgniter\HotReloader\HotReloader;

Events::on(
'DBQuery',
static function (\CodeIgniter\Database\Query $query) {
static function (Query $query) {
log_message('info', (string) $query);
},
);
Expand Down
4 changes: 3 additions & 1 deletion docs/database/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ The following code loads and initializes the database class based on your [confi
```php
<?php

$db = \Config\Database::connect();
use Config\Database;

$db = Database::connect();
```

Once loaded, the class is ready to be used as described below.
Expand Down
4 changes: 3 additions & 1 deletion docs/database/query_builder.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ The Query Builder is loaded through the `table()` method on the database connect
```php
<?php

$db = \Config\Database::connect();
use Config\Database;

$db = Database::connect();
$builder = $db->table('users');
```

Expand Down
Loading