scorninpc/slim-mvc-skel 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

scorninpc/slim-mvc-skel

Composer 安装命令:

composer require scorninpc/slim-mvc-skel

包简介

Skeleton of Slim Framework 4 with Smarty

README 文档

README

Version Total Downloads GitHub GitHub issues

Slim MVC Skell with Smarty template engine

This is pure slim framework 4 with Smarty template engine skeleton. This project is only a index.php and directory structure to get templates from pre-defined locations based on controller/action

Built With

I could not have created this skeleton without the following contributions:

Installation

Just clone this repository, and download dependencies with composer

$ git clone https://github.com/scorninpc/slim-mvc-skel.git mywebsite.com.br
$ cd mywebsite.com.br
$ composer update
$ php -S localhost:8080

This commands will:

  • download this repository;
  • update dependencies, like slim and smarty;
  • create auload
  • start php build-in server

Getting Started

To create a new page, you need:

  • create a new route
  • create or use a existing controller
  • create a action
  • create the template file

Routes

Routes are located on application/configs/routes.php files. This structure are simple:

'test' => [                             // Name of route
	'pattern' => "/hello[/{somevar}]",  // URL
	'type' => ['GET'],                  // Type
	'defaults' => [
		'module' => "main",             // Controller
		'controller' => "index",        // Controller
		'action' => "hello",            // Action
		'somevar' => 1                  // Some parameter, default if not passed on url
	],
],

Controllers

Now you need to create the controller, located on Controller directory of the module. The pattern are create with nameController.php, like productsController.php or pagesController.php The class must extends \Slim\Mvc\Controller to provide the view and create location of template files

Actions

With controller on hands, now its time to create the action, who will trigged on page access. When user access the route, the skel will call nameController::nameAction() method. So, if you have a route that call products controller, and details action, the skel will trigger productsController::detailsAction()

In that example, your controller will be something like:

<?php

namespace Application\Main\Controllers;

class productsController extends \Slim\Mvc\Controller
{

	public function detailsAction()
	{
		
	}
}

Views

This skel will use the pattern ControllerName + ActionName to create a path of template file, located on Views directory. So on the example above, you will create the file application/modules/Main/Views/products/details.tpl to store your HTML of this page, who will added to application/modules/Main/Views/layouts/template.tpl layout content.

Modules

Now this skell use modules as default, but if you want to remove modules, change routes to remove modules variable from routes. Something like:

'test' => [                                     // Name of route
	'pattern' => "/hello[/{somevar}]",      // URL
	'type' => ['GET'],                      // Type
	'defaults' => [
		//'module' => "main",           // Module
		'controller' => "index",        // Controller
		'action' => "hello",            // Action
		'somevar' => 1                  // Some parameter, default if not passed on url
	],
],

And need to remove module directory folder from application/configs/config.development.php. Something like:

	'application' => [
		'name' => "Application",
		'location' => dirname(__FILE__) . "/..",
		// 'modules_location' => dirname(__FILE__) . "/../modules",
	],

Now you need to change `composer.json`` to change directory of your classes:

	"autoload": {
        "psr-4": {
            "Application\\": "application/"
        }
    }

This will look for controller in application/Controllers/indexController.php, action helloAction(), and will look for template in application/Views/index/hello.tpl

Contributing

If you want to help, just use it. Use issues tab to recommend anything that can help, like some config, some library like database, or anything usefull

Authors

Credits

I cannot forget to thanks Slim equip, to provide some fast, minimalist and cute framework, and Smarty community for the better template enginer created

License

This use GNU v3.0. This permissions are strong copyleft license and are conditioned on making available complete source code of licensed works and modifications, which include larger works using a licensed work, under the same license. Copyright and license notices must be preserved. Contributors provide an express grant of patent rights.

But if you use this skel to make money, please lets the 1% giveaway for devs like me, or slim, or smarty. Dont forget that are alot people making stuffs for free, to you make money

scorninpc/slim-mvc-skel 适用场景与选型建议

scorninpc/slim-mvc-skel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 04 月 25 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「framework」 「bootstrap」 「smarty」 「mvc」 「slim」 「skel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 scorninpc/slim-mvc-skel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 scorninpc/slim-mvc-skel 我们能提供哪些服务?
定制开发 / 二次开发

基于 scorninpc/slim-mvc-skel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 8
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-04-25