Skip to content
Permalink
Browse files

Remove cli system from the framework. It's forwarded into this own mo…

…dule
  • Loading branch information...
bulton-fr committed Mar 8, 2019
1 parent 1351ed2 commit 02fb2f2e37571b34ced610b8e95a7c3a947c3b49
Showing with 177 additions and 1,540 deletions.
  1. +0 −3 bin/bfwInstall
  2. +2 −0 bin/bfwInstallModules
  3. +0 −3 docs/en/added-constants.md
  4. +0 −27 docs/en/core-classes/AppSystems.md
  5. +0 −71 docs/en/core-classes/Cli.md
  6. +1 −1 docs/en/core-classes/ErrorsDisplay.md
  7. +4 −10 docs/en/get-started/config.md
  8. +1 −40 docs/en/get-started/example-scripts.md
  9. +0 −3 docs/en/get-started/install.md
  10. +0 −113 docs/en/helpers/Cli.md
  11. +1 −1 docs/en/helpers/Dates.md
  12. +4 −0 docs/en/how-it-works/existing-modules.md
  13. +4 −9 docs/en/how-it-works/readme.md
  14. +0 −1 docs/en/others-classes/Application.md
  15. +0 −2 docs/en/readme.md
  16. +14 −0 skel/app/config/bfw/modules.php
  17. +0 −30 skel/cli.php
  18. +0 −30 skel/src/cli/exemple.php
  19. +0 −3 skel/web/index.php
  20. +46 −2 src/Application.php
  21. +0 −78 src/Core/AppSystems/Cli.php
  22. +0 −2 src/Core/AppSystems/Constants.php
  23. +0 −114 src/Core/Cli.php
  24. +1 −9 src/Core/ErrorsDisplay.php
  25. +0 −196 src/Helpers/Cli.php
  26. +0 −1 src/Install/Application.php
  27. +6 −5 src/Install/Core/AppSystems/ModuleInstall.php
  28. +31 −30 src/Install/ModuleInstall.php
  29. +61 −0 src/Traits/BasicCliMsg.php
  30. +0 −9 test/bin/installFwk.php
  31. +0 −2 test/unit/mocks/src/Application.php
  32. +0 −14 test/unit/mocks/src/Core/AppSystems/Cli.php
  33. +0 −139 test/unit/mocks/src/Core/Cli.php
  34. +0 −27 test/unit/mocks/src/Helpers/Cli.php
  35. +1 −3 test/unit/src/Application.php
  36. +0 −133 test/unit/src/Core/AppSystems/Cli.php
  37. +0 −3 test/unit/src/Core/AppSystems/Constants.php
  38. +0 −28 test/unit/src/Core/AppSystems/CtrlRouterLink.php
  39. +0 −112 test/unit/src/Core/Cli.php
  40. +0 −286 test/unit/src/Helpers/Cli.php
@@ -149,7 +149,6 @@ createDirectory "app/modules"

## src Directories
createDirectory "src"
createDirectory "src/cli"

## web Directory
createDirectory "web"
@@ -160,14 +159,12 @@ searchBfwPath

# Copy skeleton files
echo ''
copyFile "skel/cli.php" "cli.php"
copyFile "skel/app/config/bfw/errors.php" "app/config/bfw/errors.php"
copyFile "skel/app/config/bfw/global.php" "app/config/bfw/global.php"
copyFile "skel/app/config/bfw/manifest.json" "app/config/bfw/manifest.json"
copyFile "skel/app/config/bfw/memcached.php" "app/config/bfw/memcached.php"
copyFile "skel/app/config/bfw/modules.php" "app/config/bfw/modules.php"
copyFile "skel/app/config/bfw/monolog.php" "app/config/bfw/monolog.php"
copyFile "skel/src/cli/exemple.php" "src/cli/exemple.php"
copyFile "skel/web/.htaccess" "web/.htaccess"
copyFile "skel/web/index.php" "web/index.php"

@@ -39,13 +39,15 @@ if (isset($cliArgs['bfw-path'])) {
} elseif (isset($cliArgs['p'])) {
$bfwPath = realpath($cliArgs['p']);
}
//echo "\033[0;33mBFW path : $bfwPath\033[0m\n";
$vendorPath = $bfwPath.'/vendor';
if (isset($cliArgs['vendor-path'])) {
$vendorPath = realpath($cliArgs['vendor-path']);
} elseif (isset($cliArgs['v'])) {
$vendorPath = realpath($cliArgs['v']);
}
//echo "\033[0;33mVendor path : $vendorPath\033[0m\n";
$reinstall = false;
if (isset($cliArgs['reinstall']) || isset($cliArgs['r'])) {
@@ -8,7 +8,4 @@ The list is :
* `CONFIG_DIR` : The path to the directory `app/config/`
* `MODULES_DIR` : The path to the directory `app/modules/`
* `SRC_DIR` : The path to the directory `src/`
* `CLI_DIR` : The path to the directory `src/cli/`
* `WEB_DIR` : The path to the directory `web/`

Front files `cli.php` and `web/index.php` also define the constant `CLI_MODE` to know if the script is run from the console or not.
@@ -42,33 +42,6 @@ This method is used by `Application` class for direct access to AppSystem.
For example, when you doing `\BFW\Application::getInstance()->getModuleList()`,
this will call the method `__invoke` of the `ModuleList` AppSystem.

## Cli

More details about `\BFW\Core\Cli` on his [dedicated page](./Cli.md).

### Property

__`protected \BFW\Core\Cli $cli;`__

### Methods

__`self public __construct()`__

Instantiate the class `\BFW\Core\Cli` and keep it into the property `$cli`.

__`\BFW\Core\Cli public __invoke()`__<br>
__`\BFW\Core\Cli public getCli()`__

Return the value of the property `$cli`.

__`void public run()`__

Call the method `runCliFile()`.

__`void protected runCliFile()`__

Check if we are in the cli mode. If it's true, search the cli file into arguments and execute it.

## ComposerLoader

### Property

This file was deleted.

@@ -18,7 +18,7 @@ The backtrace is not displayed.

#### Example

For example, I have edited the file `src/cli/exemple.php` and add the line `throw new \Exception('Test');`.
For example, I have install the bfw-cli module, edit the file `src/cli/exemple.php` and add the line `throw new \Exception('Test');`.

Note : The line "Error detected..." is the line which is normally written in the php log.
It's my local config of php which write the line in the output.
@@ -51,16 +51,6 @@ Can be used by a debug bar module for example.

Without module, the only utility is to enable personal errors pages (defined into `errors.php` config files).

#### sqlSecureMethod

Used by Secure helper. You can define a function to secure data against SQL injections.
If no function is defined, the helper will use the function [addslashes](http://php.net/manual/en/function.addslashes.php).

For example, with the method [PDO::quote](http://php.net/manual/en/pdo.quote.php),
you should define this config to `'sqlSecureMethod' => ['\PDO', 'quote']`.

The choice is free because you can add a module who integrate other functions to do this.

### memcached.php

To use a memcache(d) server.
@@ -93,6 +83,10 @@ However, router and controller modules can be helpful for a web application :)

For each module, `name` is the module name and `enabled` this status (enabled or not).

#### cli

Used for the module who manages cli files

#### db

Used for the module who manages the link with the database, models, etc...
@@ -2,46 +2,7 @@

## Cli script

There is a script called `cli.php` into the root directory of your application.
This file will execute cli script with the framework loaded.

When you use it, you should indicate the parameter `-f` to say what file (into directory `src/cli/`) to execute.
The argument value must never have the script extension. The `.php` extension is added by the system.

There is an example cli file provided.
```
$ ls src/cli/
exemple.php
```

To play the script, you should do :
```
$ php cli.php -f=exemple
CLI Exemple file
```

Note : We use the function [getopt()](http://php.net/manual/en/function.getopt.php), so take the time to understand how to pass parameters values.

The parameters `-f` is mandatory for `/cli.php` script, but all cli script executed by him can also have their own parameters.

For example :
```
$ php cli.php -f=exemple -h
CLI Exemple file
Helping Informations : Parameters script
* -v --version : Version of test script
* -p --parameters : Display args array
* -h --help : View this message
$ php cli.php -f=exemple -p
CLI Exemple file
Array
(
[f] => exemple
[p] =>
)
```
Please refer to doc of the cli module you will use.

## Web script

@@ -22,20 +22,17 @@ Run BFW Install
> Create app/config/bfw directory ... Done
> Create app/modules directory ... Done
> Create src directory ... Done
> Create src/view directory ... Done
> Create web directory ... Done
> Search BFW vendor directory path ... Found
BFW path : /opt/dev/bfw/test/vendor/bulton-fr/bfw
> Copy skel/cli.php file to cli.php ... Done
> Copy skel/app/config/bfw/errors.php file to app/config/bfw/errors.php ... Done
> Copy skel/app/config/bfw/global.php file to app/config/bfw/global.php ... Done
> Copy skel/app/config/bfw/manifest.json file to app/config/bfw/manifest.json ... Done
> Copy skel/app/config/bfw/memcached.php file to app/config/bfw/memcached.php ... Done
> Copy skel/app/config/bfw/modules.php file to app/config/bfw/modules.php ... Done
> Copy skel/app/config/bfw/monolog.php file to app/config/bfw/monolog.php ... Done
> Copy skel/src/cli/exemple.php file to src/cli/exemple.php ... Done
> Copy skel/web/.htaccess file to web/.htaccess ... Done
> Copy skel/web/index.php file to web/index.php ... Done

This file was deleted.

@@ -218,7 +218,7 @@ And the expression `{time}` will be replaced by the `$time` value.

### Example

I create a cli script (so into `/src/cli/`) for example.
I create a cli script (with bfw-cli module, and into `/src/cli/`) for example.
I add into comments the output.

```php
@@ -2,6 +2,10 @@

## Core

### Cli

* [bulton-fr/bfw-cli](https://github.com/bulton-fr/bfw-cli)

### Database

* [bulton-fr/bfw-sql](https://github.com/bulton-fr/bfw-sql)

0 comments on commit 02fb2f2

Please sign in to comment.
You can’t perform that action at this time.