Download the PHP package pureisle/micro-mvc without Composer

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

为什么用

框架工具库说明

其中{project_name}替换成目标项目名,{module_name}替换成目标模块名。

文件目录

文件结构也体现了 "DMVC+C" 的分层思想。

详细的情况可以参见 Sso Module,有更多的使用样例,包括 Cache、config、Bootstrap.php等

开始使用

MVC框架

  1. 配置 Web Server 服务器重定向到入口文件。Nginx 样例如下:

  2. 路由解析规则:域名后第一个用'/'分离的部分为 module 名,最后一部分为 action 名,中间部分解析为 controller。如:

这里要注意,url结尾有没有"/"很关键,结尾有"/"意味着 Action 的值会解析成 index 。
样例项目中,访问 sso 地址为: http://domain.example.com/sso/login

  1. 每个 module 可以有自己的 Bootstrap.php 在自己的根目录里,在框架初始化时会顺序执行'_init'开头的成员方法。
  2. 每个 module 有自己的路由插件在 Plugins 文件夹内,可以在 Bootstrap 类中调用 Dispatcher 类的 registerPlugin 方法进行插件注册。 插件包含routerStartup、routerShutdown、dispatchStartup、dispatchShutdown、preResponse几个部分。分别为:

  3. 每个 Controller 类必须继承 Framework\Models\Controller 。Controller 中的 Action 后缀类成员方法为可以调用的接口。
    每个接口可以定义一个对应的参数合法性检验的静态变量,静态变量名的对应规则为: "全大写的接口名_PARAM_RULES"。如 'indexAction' 的参数定义如下:

  4. 每个 Action 若返回结果不为 False ,则会加载相应的 View 视图,视图可以混写 PHP 代码。
    在Action内可以调用 $this->assign() 方法注册渲染变量。如:$this->assign(array('text' => 'Hello,world!'));
    相应的视图加载规则: Controller名\Action名.phtml。如:

老项目使用MicroMVC框架工具库

其中 exec_function 为要执行的函数, $argv 是参数列表,可以不传或为空。

如何进行仿真环境配置文件加载重定向

  1. 在 config 下创建 {env_name} 文件夹, {env_name} 名字任意,'pro' 为保留的关键字,视为生产环境标志。文件夹内的配置文件命名同正式的配置文件名即可;
  2. ConfigTool 加载配置文件时,会依次判断静态变量 $_env 、 $_COOKIE['VISIT_SERVER_ENV'] 和 $_SERVER['VISIT_SERVER_ENV'],如有设置环境名,则启用相应环境的配置文件夹下的同名配置文件。
  3. \Framework\Libraries\Tools::setEnv(string $env) 可以设置环境名,此时会给 静态变量 $_env 和 setcookie()。
  4. 样例参考 Sso 下的 config\dev\database.php 和 config\database.php ,分别会在仿真环境和生产环境读取。生产环境下,不会重定向到非生产环境的配置文件,Tools::getEnv() 强制返回生产环境标志,以防止cookie伪造。

如何使用接口认证

如何进行性能优化

  1. 在想进行代码优化的开始位置执行以下代码:

  2. 随后在进程结束后会给出查看程序执行细节profile的链接,点击查看即可。

如何使用框架提供的异常处理服务

  1. 参考Sso\Bootstrap.php 初始化函数:

  2. 告诉框架自己想要处理的异常 "\Framework\Models\ControllerException" 以及处理该异常的匿名函数即可。
  3. 这里有一点需要注意,匿名函数可以有返回值告诉框架,这个异常是否处理成功,如果返回 false ,则框架认为未处理成功,会继续抛出这个异常。

All versions of micro-mvc with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
phpmailer/phpmailer Version ~6.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 pureisle/micro-mvc contains the following files

Loading the files please wait ....