Skip to content

Commit

Permalink
Merge pull request #18 from gacela-project/feature/fixes-documentation
Browse files Browse the repository at this point in the history
Fixes documentation
  • Loading branch information
Chemaclass authored Apr 18, 2021
2 parents 9838f75 + 84e67c2 commit a007e9b
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 33 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<p align="center">
<a href="http://gacela-project.com/" title="Gacela Website">
<img src="docs/imgs/gacela-logo.png" width="350" alt="Gacela logo"/>
</a>
</p>

<p align="center">
<a href="https://github.com/gacela-project/gacela/actions">
<img src="https://github.com/gacela-project/gacela/workflows/CI/badge.svg" alt="GitHub Build Status">
Expand Down Expand Up @@ -40,8 +46,9 @@ composer require gacela-project/gacela
- [Basic concepts](docs/001_basic_concepts.md): What are the characteristics of a module?
- [Facade](docs/002_facade.md): The entry point of your module
- [Factory](docs/003_factory.md): The place where you create your domain services and objects
- [Config](docs/004_config.md): Reads the `config` key-values
- [Config](docs/004_config.md): Reads the all the files under the `config` folder
- [DependencyProvider](docs/005_dependency_provider.md): It defines the dependencies between modules
- [Code generator](docs/006_code_generator.md): Some commands out-of-the-box for generating code

### Examples

Expand Down
5 changes: 3 additions & 2 deletions docs/001_basic_concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ You should consider a module as an individual thing in order to decouple it from
charge of reading from the IO (Config) is the only class which is coupled somehow with the infrastructure, but the rest
should be decouple from the outside.

All the responsibilities that a module handles should remain close and together. The domain of that module should guide its
design.
All the responsibilities that a module handles should remain close and together. The domain of that module should guide
its design.

[Facade >>](../docs/002_facade.md)
16 changes: 9 additions & 7 deletions docs/002_facade.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
The Facade is the entry point of your module. See an example:

```php
# src/Calculator/CalculatorFacadeInterface.php
interface CalculatorFacadeInterface
# src/Calculator/FacadeInterface.php
interface FacadeInterface
{
public function sum(): void;
}
```

```php
# src/Calculator/CalculatorFacade.php
# src/Calculator/Facade.php
/**
* @method CalculatorFactory getFactory()
* @method Factory getFactory()
*/
final class CalculatorFacade extends AbstractFacade implements CalculatorFacadeInterface
final class Facade extends AbstractFacade implements FacadeInterface
{
public function sum(int ...$numbers): int
{
Expand All @@ -31,9 +31,11 @@ final class CalculatorFacade extends AbstractFacade implements CalculatorFacadeI
A Facade is a "ready to use" thing:

```php
$facade = new CalculatorFacade();
$facade = new Facade();
$result = $facade->sum(2, 3);
```

The Facade uses the Factory to create the module's domain instances and executes the desired behaviour from them.
The Facade uses the Factory to create the module's domain instances and executes the desired behaviour from them.
Nothing less, nothing more.

[<< Basic Concepts](../docs/001_basic_concepts.md) | [Factory >>](../docs/003_factory.md)
16 changes: 9 additions & 7 deletions docs/003_factory.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

# Factory

The Factory is the place where you create your domain services and objects.
The Factory is the place where you create your domain services and objects.
The Facade is the class that can access the Factory.

```php
# src/Calculator/CalculatorFactory.php
# src/Calculator/Factory.php
/**
* @method CalculatorConfig getConfig()
* @method Config getConfig()
*/
final class CalculatorFactory extends AbstractFactory
final class Factory extends AbstractFactory
{
public function createAdder(): AdderInterface
{
Expand All @@ -22,11 +22,11 @@ final class CalculatorFactory extends AbstractFactory
```

```php
# src/Calculator/CalculatorFacade.php
# src/Calculator/Facade.php
/**
* @method CalculatorFactory getFactory()
* @method Factory getFactory()
*/
final class CalculatorFacade extends AbstractFacade implements CalculatorFacadeInterface
final class Facade extends AbstractFacade implements FacadeInterface
{
public function sum(int ...$numbers): int
{
Expand All @@ -36,3 +36,5 @@ final class CalculatorFacade extends AbstractFacade implements CalculatorFacadeI
}
}
```

[<< Facade](../docs/002_facade.md) | [Config >>](../docs/004_config.md)
22 changes: 15 additions & 7 deletions docs/004_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ Extra:

```php
# config/default.php
use src\Calculator\CalculatorConfig;
use src\Calculator\Config;

return [
CalculatorConfig::MAX_ADDITIONS => 20,
Config::MAX_ADDITIONS => 20,
];
```

```php
# src/Calculator/CalculatorConfig.php
final class CalculatorConfig extends AbstractConfig
# src/Calculator/Config.php
final class Config extends AbstractConfig
{
public const MAX_ADDITIONS = 'MAX_ADDITIONS';

Expand All @@ -46,11 +46,11 @@ final class CalculatorConfig extends AbstractConfig
```

```php
# src/Calculator/CalculatorFactory.php
# src/Calculator/Factory.php
/**
* @method CalculatorConfig getConfig()
* @method Config getConfig()
*/
final class CalculatorFactory extends AbstractFactory
final class Factory extends AbstractFactory
{
public function createAdder(): AdderInterface
{
Expand All @@ -60,3 +60,11 @@ final class CalculatorFactory extends AbstractFactory
}
}
```

Do not forget to define the `$applicationRootDir` in your bootstrap application file.

```php
\Gacela\Framework\Config::setApplicationRootDir(getcwd());
```

[<< Factory](../docs/003_factory.md) | [Dependency Provider >>](../docs/005_dependency_provider.md)
17 changes: 9 additions & 8 deletions docs/005_dependency_provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@

This is the place where you can define the dependencies that a particular module has with other modules.

In this example you can see that in the `Calculator` we have a service (`Adder`) which needs the
`AnotherModuleFacade` as a dependency. In this case, we can define the dependency inside the
`CalculatorDependencyProvider`.
In this example you can see that in the `Calculator` we have a service (`Adder`) which needs the `AnotherModuleFacade`
as a dependency. In this case, we can define the dependency inside the `DependencyProvider`.

```php
# src/Calculator/CalculatorFactory.php
final class CalculatorFactory extends AbstractFactory
# src/Calculator/Factory.php
final class Factory extends AbstractFactory
{
public function createAdder(): AdderInterface
{
Expand All @@ -21,14 +20,14 @@ final class CalculatorFactory extends AbstractFactory

private function getAnotherModuleFacade(): AnotherModuleFacade
{
return $this->getProvidedDependency(CalculatorDependencyProvider::FACADE_ANOTHER_MODULE);
return $this->getProvidedDependency(DependencyProvider::FACADE_ANOTHER_MODULE);
}
}
```

```php
# src/Calculator/CalculatorDependencyProvider.php
final class CalculatorDependencyProvider extends AbstractDependencyProvider
# src/Calculator/DependencyProvider.php
final class DependencyProvider extends AbstractDependencyProvider
{
public const FACADE_ANOTHER_MODULE = 'FACADE_ANOTHER_MODULE';

Expand All @@ -45,3 +44,5 @@ final class CalculatorDependencyProvider extends AbstractDependencyProvider
}
}
```

[<< Config](../docs/004_config.md) | [Code Generator >>](../docs/006_code_generator.md)
18 changes: 18 additions & 0 deletions docs/006_code_generator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[Back to the index](../docs)

# Code Generator

Gacela Framework provides you some commands out-of-the-box to generate a `facade`, `factory`, `config`,
`dependency provider` or a full `module` with a single command.

- `make:module <target-namespace>`: Create a new Facade, Factory, Config, and DependencyProvider
- `make:facade <target-namespace>`: Create a new Facade
- `make:factory <target-namespace>`: Create a new Factory
- `make:config <target-namespace>`: Create a new Config
- `make:dependency-provider <target-namespace>`: Create a new DependencyProvider


Example:
`./vendor/bin/gacela make:module App/TestModule`

[<< Dependency Provider](../docs/005_dependency_provider.md)
7 changes: 6 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
[Back to the homepage](../README.md)

<p align="center">
<img src="imgs/gacela-logo.png" width="350" alt="Gacela logo"/>
</p>

## Documentation

- [How to start](001_basic_concepts.md)
- [Facade](002_facade.md): The entry point of your module
- [Factory](003_factory.md): The place where you create your domain services and objects
- [Config](004_config.md): Reads the `config.php` key-values
- [Config](004_config.md): Reads the all the files under the `config` folder
- [DependencyProvider](005_dependency_provider.md): It defines the dependencies between modules
- [Code generator](006_code_generator.md): Some commands out-of-the-box for generating code
Binary file added docs/imgs/gacela-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a007e9b

Please sign in to comment.