Download the PHP package firerabbit/engine without Composer

On this page you can find all versions of the php package firerabbit/engine. 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 engine

火兔引擎

基于 swoole 的个人框架。

此框架为本人练习技术所用,切勿用于生产环境。

此框架适合初学者入门 swoole(本人也是初学者),封装了基本的路由、中间件、控制器和任务等。

由于本人十分喜欢 Laravel,但是 Laravel 的性能感人,因此此框架在很大程度上模仿了 Laravel 的习惯。

如果你之前用过 Laravel,再使用此框架基本可以立即上手。

我的博客记录了框架的开发过程,如有兴趣可前往了解。

博客地址:http://huotublog.com

博文还包括使用此框架开发一个博客系统。

环境要求

Nginx 配置

本框架需要配合 nginx 使用,swoole 处理动态文件,nginx 处理静态资源。

如果你用的不是 docker 环境,proxy_pass 应该改为:

安装框架

新建一个空文件夹,即你的项目名字,如:blog。

进入 blog,执行:composer require firerabbit/engine 即可完成框架安装。

项目结构

项目文件的结构完全由你自定义,例如下面这个样子(需要你自己创建文件夹):

QQ20210219-134621.jpg

对应的配置文件及代码,如下说明。

自动加载

给你的项目添加自动加载,修改 composer.json:

加入 autoload 字段,然后执行 composer dump-autoload 重新生成自动加载文件即可。

快速开始

只要仿照本文例子的文件结构及代码,即可直接启动框架实现简单页面的展示。

app.php

这是项目的基础配置文件,包括框架配置以及你的个人项目配置。

framework 字段定义了框架的配置。

middleware.php

中间件的配置,用来建立中间件名称与对应的中间件类的映射关系,现在没有中间件,直接返回空数组即可。

IndexController

控制器类,路由最终会解析成为某个控制器的方法。

现在只需要一个简单的输出即可。

web.php

路由配置文件,路由规则与 Laravel 相似。

上述定义了一个路由 "/",解析到 IndexController 的 index 方法。

除此之外还可以使用下面这种带路径参数的:

group 方法可以给路由分组,在同一组的路由具有相同配置,如命名空间,中间件等等。

启动文件

在项目根目录创建一个 http_server.php:

然后在控制台执行代码:php http_server.php 即可启动 swoole 程序。

此处设定端口为 9527,因此只要访问 127.0.0.1:9527 即可看到网页输出了“hello world!”

至此,一个简单的路由+控制器就完成了。

Model

数据库采用与 Laravel 完全相同的 ORM。

在项目的 Model 目录新建一个测试类:

所有的 Model 只要继承 Illuminate\Database\Eloquent\Model 就拥有了增删改查等等功能。

示例代码:

Blade 模板

视图采用 blade 模板。

日志系统

调用方法:

日志存放位置可在 app.php 配置。

Cache

框架实现了简单的缓存系统,目前只有 redis 驱动可用。

示例代码:

邮件系统

框架集成了 PHPmailer,可以实现非常简单的发送邮件。

示例代码:

邮件需要自行申请并且开通 STMP 服务。

JWT 用户认证

框架提供 JWT token 生成和解析服务,JWT 可用于用户身份认证。

示例代码:

直接调用 Auth 类即可。

中间件

中间件可以用来拦截某些不符合要求的请求,例如表单验证,用户身份验证(未登录则跳转到登录页),诸如此类。

示例代码:

首先定义一个中间件,在 Middleware 文件夹新建:

上述中间件将会阻止路径上带有 a 参数且参数值等于 1 的路由。

定义好中间件后,需要将中间件加入到映射关系,编辑 app/config/middleware.php:

将这个中间件命名为 a。

然后只需要在路由配置处加上中间件即可:

异步任务

框架实现了 swoole 异步任务的封装,并且集成到了 Controller 里。

在 Controller 可以非常简单的分发一个任务。

如果需要执行任务,需要创建一个任务类,在 app/Http/Task 下新建一个任务类:

这是一个发送邮件的任务类,任务是异步调用的,所以程序会直接返回,不会因为发送邮件缓慢而卡住。

然后回到 IndexController,调用任务的方法:

最后的话

框架现在只有基本功能,很多地方都还有改进空间。

后续有时间也会不断更新。

如有疑问可联系:QQ874811226

火兔博客:http://huotublog.com


All versions of engine with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4
illuminate/database Version ^7.30
xiaoler/blade Version ^5.4
monolog/monolog Version ^2.2
firebase/php-jwt Version ^5.2
phpmailer/phpmailer Version ^6.2
guzzlehttp/guzzle Version ^7.2
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 firerabbit/engine contains the following files

Loading the files please wait ....