mejuliver / jframework
此软件包最新版本(dev-master)没有可用的许可证信息。
轻量级PHP MVC框架
dev-master
2019-02-19 08:33 UTC
This package is auto-updated.
Last update: 2024-09-12 19:38:57 UTC
README
轻量级MVC PHP应用程序框架
路由
在此处您可以定义您的路由
示例
$route['sample'] = [
false, // specify the default template name, if declared an controller, this will not be read
'sample_controller@sample', // controller name, the '@' symbol is a delimiter between your controller name and the method e.g controller@method, if no method, index will be use by default
false // models, provide an array if multiple e.g. ['model1','model2','model3']. If false, all models in the models folder will be loaded
];
参考routes.php
控制器
所有控制器必须放在“controllers”文件夹中。请参阅“controllers/Sample_controller.php”示例。
模型
所有模型必须放在“models”文件夹中。请参阅“models/Sample_model.php”示例
示例
//initialize model
use App\Models\ModelName as model
然后通过以下方式初始化它
$model = new ModelName();
到您的控制器;
视图
所有模板或与视图相关的内容必须放在“templates”文件夹中。
您可以直接调用视图,无需在路由中指定控制器名称。如果已声明控制器,则将跳过视图名称
$route['home'] = [home_template] // this can be found inside the templates folder
配置
(config.php) 在此处您可以放置所有应用程序的配置。一些默认和必需的设置包括
$app['url'] = ''; // leave this empty if app is not hosted on shared hosting
$app['title'] = '' // specify your app title
$app['db']['mysql'] = [..]; // database settings
推荐包
https://respect-validation.readthedocs.io/en/1.1/ 输入验证
use \Respect\Validation\Validator as v;
https://github.com/ThingEngineer/PHP-MySQLi-Database-Class MySQL包装器
use \MysqliDb as sqldb;
https://github.com/PHPMailer/PHPMailer 邮件包装器
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;