Download the PHP package anyuzhe/laravel-function-flow without Composer

On this page you can find all versions of the php package anyuzhe/laravel-function-flow. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-function-flow

mvc模式里的 c 也就是控制器,在每次编写代码的过程中,其中有一大部分高度复用的 如果把这部分代码解耦出来,并且保证其原子性,成为可以高度复用的方法,可以带来极大的好处 可以减少重复的代码,在减少代码的同时也会减少bug代码的产生,并且容易修改 这是Repository模式的作用

那控制器里的代码 有多少可以封装到respository类里呢? 我觉得是90%以上(除了调用代码) 所以我在这里想提出一种模式 也就是标题 方法容器-流程控制模式

简单来说就是 有一个方法容器,可以依次调用你定义的方法(也就是respository里的方法),最后返回参数

  1. 它的好处是,像laravel调用控制器的方法一样 自动传入参数,你只需要在方法中申明需要的参数 方法容器去调用的时候,会自动传入参数,这些参数就是方法容器类里的参数这个属性里的,或者是laravel容器里定义的对象(这个就和控制器里的一样) 变量是前者,而申明的是类就是后者 抄袭了laravel里的代码
  2. 可以对单个方法做缓存
  3. 强迫自己写原子性的方法,提高代码的复用
  4. 让控制器里的代码非常直观

而在写控制器方法的时候,其实写的是调用流程,我们一起来看一下到底是咋回事

这是git仓库(看名字就知道 依赖于laravel) laravel-function-flow

首先用composer加载包

composer require anyuzhe/laravel-function-flow

在配置文件config/app.php的服务容器数组中加入

\Anyuzhe\LaravelFunctionFlow\FunctionFlowServiceProvider::class,

在门面数组中加入

'Flow' => \Anyuzhe\LaravelFunctionFlow\FlowFacade::class,

执行命令 生成配置文件

php artisan funcFlow:publish

会在config文件夹中生成function-flow.php文件

可在里面配置仓库类 类似如下

`

以下是控制器中的使用示例 `

首先除了flow方法。别的方法调用都是返回对象本身 所以可以链式调用 以上是facade模式的调用 再看一下这个详细的例子

` 此例子中并没有使用setLastFunc方法(用来设置最后运行方法的) 需要注意的是缓存是用了类名+方法名+参数转成字符串的值作为缓存的键名。 可以适用于一些场景 可以配合前面函数输出缓存的依据参数 配合使用应该还不错

最后看一下 几个方法的实例 了解下方法的编写 注意方法中的参数都是通过方法容器自动传入的(变量名与参数名相同) 如果方法容器的参数数组中不存在并且没有默认值 会传入null flow方法会把方法容器的parameters成员返回 也就是所有的参数

`

`

`

有兴趣的小伙伴可以体验一下,也可以来github上提bug和问题,我会立刻改正


All versions of laravel-function-flow with dependencies

PHP Build Version
Package Version
Requires illuminate/support Version >=5.0
illuminate/container Version >=5.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package anyuzhe/laravel-function-flow contains the following files

Loading the files please wait ....