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
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added connection state validation with `ensureConnection()` method
- **Environment Configuration**: Fixed path handling by removing unreliable `realpath()` usage
- **Configuration Loader**: Improved validation and error handling
- **Messaging System**: Fixed PHPUnit mock issues and corrected type signatures
- **Notifier System**: Fixed PHPUnit mock issues and corrected type signatures
- **Test Suite**: Renamed test methods to snake_case for consistency
- **Database Tests**: Significantly expanded test coverage across connection, migration, pagination, and query builders

Expand All @@ -44,7 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **FTP Service**: Fixed directory listing parser to handle filenames with spaces
- **FTP Service**: Improved error messages with connection details
- **Environment Configuration**: Fixed `Env::configure()` error handling
- **Queue Tests**: Fixed mock configuration issues in MessagingTest
- **Queue Tests**: Fixed mock configuration issues in NotifierTest
- **Notification Tests**: Added missing timestamp columns in test schema

### Improved
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ The project is organized into the following directories, each representing an in
- **Event/**: Event management and dispatching.
- **Http/**: HTTP requests and responses management.
- **Mail/**: Email sending and configuration.
- **Messaging/**: Messaging and notifications.
- **Notifier/**: Notifications.
- **Middleware/**: Middleware classes for request handling.
- **Queue/**: Job queues and background processing.
- **Router/**: HTTP request routing.
Expand Down
10 changes: 6 additions & 4 deletions src/Configuration/EnvConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,20 @@ class EnvConfiguration extends Configuration
*/
public function create(Loader $config): void
{
Env::configure(base_path('.env.json'));
$this->container->bind('env', function () use ($config) {
Env::configure($config['app.env_file'] ?? null);

$event = Env::getInstance();
$event = Env::getInstance();

$this->container->instance('env', $event);
$this->container->instance('env', $event);
});
}

/**
* @inheritdoc
*/
public function run(): void
{
// Nothing to do
// $this->container->make('env');
}
}
36 changes: 19 additions & 17 deletions src/Configuration/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,13 @@ public function boot(): Loader
$container = Capsule::getInstance();

// Load the env configuration first
$this->createConfiguration(EnvConfiguration::class, $container);
$env_config = $this->createConfiguration(EnvConfiguration::class, $container);

// Load the .env or .env.json file
$this->loadEnvfile();

$env_config->run();

// Configuration of services
$loaded_configurations = $this->createConfigurations(
array_merge([CompassConfiguration::class], $this->configurations()),
Expand Down Expand Up @@ -339,22 +341,6 @@ public function events(): array
];
}

/**
* __invoke
*
* @param string $key
* @param mixed $value
* @return mixed
*/
public function __invoke(string $key, mixed $value = null): mixed
{
if ($value == null) {
return $this->config[$key];
}

return $this->config[$key] = $value;
}

/**
* @inheritDoc
*/
Expand Down Expand Up @@ -391,4 +377,20 @@ public function offsetUnset(mixed $offset): void
{
$this->config->offsetUnset($offset);
}

/**
* __invoke
*
* @param string $key
* @param mixed $value
* @return mixed
*/
public function __invoke(string $key, mixed $value = null): mixed
{
if ($value == null) {
return $this->config[$key];
}

return $this->config[$key] = $value;
}
}
4 changes: 2 additions & 2 deletions src/Console/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use Bow\Console\Command\Generator\GenerateSessionCommand;
use Bow\Console\Command\Generator\GenerateAppEventCommand;
use Bow\Console\Command\Generator\GenerateExceptionCommand;
use Bow\Console\Command\Generator\GenerateMessagingCommand;
use Bow\Console\Command\Generator\GenerateNotifierCommand;
use Bow\Console\Command\Generator\GenerateMigrationCommand;
use Bow\Console\Command\Generator\GenerateControllerCommand;
use Bow\Console\Command\Generator\GenerateMiddlewareCommand;
Expand Down Expand Up @@ -59,7 +59,7 @@ class Command extends AbstractCommand
"add:listener" => GenerateEventListenerCommand::class,
"add:job" => GenerateJobCommand::class,
"add:command" => GenerateConsoleCommand::class,
"add:message" => GenerateMessagingCommand::class,
"add:notifier" => GenerateNotifierCommand::class,
"run:console" => ReplCommand::class,
"run:server" => ServerCommand::class,
"run:worker" => WorkerCommand::class,
Expand Down
40 changes: 0 additions & 40 deletions src/Console/Command/Generator/GenerateMessagingCommand.php

This file was deleted.

39 changes: 39 additions & 0 deletions src/Console/Command/Generator/GenerateNotifierCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

namespace Bow\Console\Command\Generator;

use Bow\Console\AbstractCommand;
use Bow\Console\Color;
use Bow\Console\Generator;

class GenerateNotifierCommand extends AbstractCommand
{
/**
* Generate session
*
* @param string $messaging
* @return void
*/
public function run(string $notifier): void
{
$generator = new Generator(
$this->setting->getNotifierDirectory(),
$notifier
);

if ($generator->fileExists()) {
echo Color::red("The notifier already exists");

exit(1);
}

$generator->write('notifier', [
'baseNamespace' => $this->namespaces['notifier'] ?? "App\\Notifier",
]);

echo Color::green("The notifier {$this->setting->getNotifierDirectory()}/{$notifier} has been well created.");
exit(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,12 @@ private function createResourceController(
string $controller,
string $model_namespace = ''
): void {
$generator->write(
'controller/rest',
[
$generator->write('controller/rest', [
'modelNamespace' => $model_namespace,
'prefix' => $prefix,
'className' => $controller,
'baseNamespace' => $this->namespaces['controller'] ?? 'App\\Controllers'
]
);
]);

echo Color::green('The controller Rest was well created.');
}
Expand Down
6 changes: 3 additions & 3 deletions src/Console/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Console
'job',
'command',
'listener',
'message'
'notifier'
];

/**
Expand Down Expand Up @@ -542,7 +542,7 @@ private function help(?string $command = null): int
\033[0;33madd:listener\033[00m Create a new event listener
\033[0;33madd:job\033[00m Create a new job
\033[0;33madd:command\033[00m Create a new console command
\033[0;33madd:message\033[00m Create a new messaging handler
\033[0;33madd:notifier\033[00m Create a new messaging handler

\033[0;32mMIGRATION\033[00m Apply migration to database
\033[0;33mmigration:migrate\033[00m Run migrations
Expand Down Expand Up @@ -595,7 +595,7 @@ private function help(?string $command = null): int
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:event name Create a new event listener
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:job name Create a new queue job
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:command name Create a new console command
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:message name Create a new messaging handler
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:notifier name Create a new messaging handler
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add help Display this help

U;
Expand Down
18 changes: 9 additions & 9 deletions src/Console/Setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ class Setting
private array $namespaces = [];

/**
* The messaging directory
* The notifier directory
*
* @var string
*/
private string $messaging_directory;
private string $notifier_directory;

/**
* Command constructor.
Expand Down Expand Up @@ -507,24 +507,24 @@ public function setMiddlewareDirectory(string $middleware_directory): void
}

/**
* Get the messaging directory
* Get the notifier directory
*
* @return string
*/
public function getMessagingDirectory(): string
public function getNotifierDirectory(): string
{
return $this->messaging_directory;
return $this->notifier_directory;
}

/**
* Set the messaging directory
* Set the notifier directory
*
* @param string $messaging_directory
* @param string $notifier_directory
* @return void
*/
public function setMessagingDirectory(string $messaging_directory): void
public function setNotifierDirectory(string $notifier_directory): void
{
$this->messaging_directory = $messaging_directory;
$this->notifier_directory = $notifier_directory;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Console/stubs/controller/controller.stub
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace {baseNamespace}{namespace};
use {baseNamespace}\Controller;
use Bow\Http\Request;

class {className} extends Controller
class {className}
{
//
}
2 changes: 1 addition & 1 deletion src/Console/stubs/controller/no-plain.stub
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace {baseNamespace}{namespace};
use {baseNamespace}\Controller;
use Bow\Http\Request;

class {className} extends Controller
class {className}
{
/**
* Application entry point
Expand Down
2 changes: 1 addition & 1 deletion src/Console/stubs/controller/rest.stub
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace {baseNamespace}{namespace};
{modelNamespace}use {baseNamespace}\Controller;
use Bow\Http\Request;

class {className} extends Controller
class {className}
{
/**
* Start point
Expand Down
2 changes: 1 addition & 1 deletion src/Console/stubs/controller/service.stub
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use {baseNamespace}\Controller;
use Bow\Http\Request;
use {serviceNamespace}\{serviceClassName};

class {className} extends Controller
class {className}
{
/**
* Instance of {serviceClassName}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ namespace {baseNamespace}{namespace};

use Bow\Database\Barry\Model;
use Bow\Mail\Envelop;
use Bow\Messaging\Messaging;
use Bow\Notifier\Notifier;

class {className} extends Messaging
class {className} extends Notifier
{
/**
* Returns the available channels to be used
Expand Down
6 changes: 6 additions & 0 deletions src/Container/Capsule.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ public function make(string $key): mixed
return $this->resolve($key);
}

if (is_string($this->registers[$key])) {
return $this->instances[$key] = $this->resolve(
$this->registers[$key]
);
}

if (is_callable($this->registers[$key])) {
return $this->instances[$key] = call_user_func_array(
$this->registers[$key],
Expand Down
4 changes: 4 additions & 0 deletions src/Container/Compass.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,10 @@ private function getInjectParameter(mixed $class): ?object
return null;
}

if (interface_exists($class_name)) {
return app()->make($class_name);
}

if (!class_exists($class_name)) {
throw new InvalidArgumentException(
sprintf('class %s not exists', $class_name)
Expand Down
Loading
Loading