承接 ngomafortuna/route-system-simple 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

ngomafortuna/route-system-simple

Composer 安装命令:

composer require ngomafortuna/route-system-simple

包简介

Simple route management system (Sistema simples de gerenciamento de rotas)

README 文档

README

Simple route management system (Sistema simples de gerenciamento de rotas)

Install

composer require ngomafortuna/route-system-simple

Require

Necessary PHP 8.0 or more (Necessário PHP 8.0 ou superior)

Exemple

Introdution

I will illustrate with a project with the following structure (Vou exemplificar com um projecto com a seguite extrutura):

  • cacutenews
    • public
    • resources
      • library
      • views
    • src
      • controllers
      • models
      • services

Start

Create the root directory cacutenews, enter the created directory and run the command composer init (Criar o directorio raiz cacutenews, entrar no directório criado e executar o comando composer init).

Edit the composer.json file, just the prs-4 block, i.e. align "App\\": "src/" (Editar o arquivo composer.json, apenas o bloco da prs-4 ou seja alinha "App\\": "src/"):

"autoload": {
    "psr-4": {
        "App\\": "src/"
    }
},

Still with composer install the component composer require ngomafortuna/route-system-simple (Ainda com composer intalar o componete composer require ngomafortuna/route-system-simple).

Update composer (Actualizar o composer composer dump-autoload).

Create the index.php file in the public directory and paste the code (Criar o arquivo index.php directório public nele cole o código):

use Ngomafortuna\RouteSystemSimple\Route;

define("PATH", dirname(__FILE__, 2)); // set 1 if index file is in root dir
define("URL", $_SERVER['HTTP_HOST']);
define("VIEWS", PATH . '/resources/views'); // path views dir
define("MAINDIR", PATH . '/src'); // path of the source code dir src
define("MAINAME", 'App'); // App is the dir of namespace, from composer.json

require_once PATH . '/vendor/autoload.php';

(new Route)->index();

On dir cacutenews/vendor/ngomafortuna/route-system-simple/test/controllers/ copy the files HomeController.php, NotFoundController.php end AboutController.php (No directorio cacutenews/vendor/ngomafortuna/route-system-simple/test/controllers/ copie os arquivos HomeController.php, NotFoundController.php e AboutController.php).

Past to dir cacutenews/src/controllers/ (Cole-os no directório cacutenews/src/controllers/).

On dir cacutenews/vendor/ngomafortuna/route-system-simple/test/views/ copy the files error.php, home.php end master.php (No directorio cacutenews/vendor/ngomafortuna/route-system-simple/test/views/ copie os arquivos about.php, error.php, home.php e master.php).

Past to dir cacutenews/resources/views/ (Cole-os no directório cacutenews/resources/views/).

Start project

In terminal access root dir cacutenews end execute this command (No terminal acesse o directório raiz cacutenews- e execute o comando abaixo):

php -S localhost:8000 -t public

In browser write http://localhost:8000

Did it work? (Funcionou?)

If it doesn't work, interpret the error returned and correct it (Caso não funcione interprete o erro retornado e corrija-o).

Create new routes

To add new routes follow these steps: (Para adicionar novas rotas siga os seguintes passos:)

  1. Create the link on one of the pages or in the menu, for example (Crie o link em uma das páginas ou no menu, por exemplo):
<li><a href="/notice">Notícias</a></li>
  1. Create the route controller in src/controllers/ with name NoticeController.php code for the controller (Crie o controller da rota em src/controllers/ com nome NoticeController.php código para o controller):
<?php

namespace App\controllers;

use Ngomafortuna\RouteSystemSimple\Controller;


class NoticeController extends Controller
{
    private array $notices = [
        'name'=>'Desporto', 
        'slag'=>'desporto', 
        'description'=>'Descrição sobre desporto'
    ];

    public function index(): void
    {
        $this->view->render('notices', [
            'title' => 'Notícias',
            'description' => 'Saiba tudo o acontece no Caute apartir daqui.'
        ]);
    }

    public function show(string $slug): void
    {
        $slug = $slug;
        $notice = $this->notices;

        $this->view->render('notices', [
            'title' => $notice['title'],
            'description' => $notice['description']
        ]);
    }
}
  1. Create in cacutenews/resources/views/ the views notices.php and notice.php with content (Criar em cacutenews/resources/views/ as views notices.php e notice.php com conteúdo):
<h1><?= $title ?></h1>
<p><?= $description ?></p>

To create other routes, just follow the same steps (Para criar outras routas é só seguir os mesmos passos).

ngomafortuna/route-system-simple 适用场景与选型建议

ngomafortuna/route-system-simple 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 06 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 ngomafortuna/route-system-simple 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-01