PHPackages                             slim4-mod/auto-route-conn - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. slim4-mod/auto-route-conn

ActiveSlim4-mod[Framework](/categories/framework)

slim4-mod/auto-route-conn
=========================

Slim4-Mod bổ sung auto-route và connect-db - sử dụng như MVC với Twig view - tích hợp SlimAsset

00PHP

Since May 16Pushed 1y ago1 watchersCompare

[ Source](https://github.com/PhiHung908/slim4-auto-route-conn)[ Packagist](https://packagist.org/packages/slim4-mod/auto-route-conn)[ RSS](/packages/slim4-mod-auto-route-conn/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Slim4-Mod auto-route
--------------------

[](#slim4-mod-auto-route)

**Tác giả:** Phi Hùng -  - (VN) 0974 471 724

---

Slim4-Mod bổ sung auto-route và connect-db - sử dụng như MVC với Twig view - tích hợp SlimAsset, nó giữ nguyên cấu trúc thư mục của slim4 gốc nhưng đã hiệu chỉnh một số file mẫu.

Các bổ sung và hiệu chỉnh là tối thiểu dể bạn có thể sử dụng slim4 tương tự như các framework-MVC thông dụng.

> *Đặc biệt:* Nó sẽ nạp các route với tính chất động (dynamic) mỗi khi người dùng gõ vào một URL nào đó. Do vậy hệ thống sẽ hoạt động nhanh và ít tốn bộ nhớ vì không mất qui trình "init" chưa cần dùng đến.

---

**Cài đặt:**

```
composer require slim4-mod/auto-route-conn "dev-master"
```

##### Cách sử dụng:

[](#cách-sử-dụng)

> Dùng tiện ích dòng lệnh để tự động tạo cấu trúc file cần thiết cho model mới (NEW\_MODEL).
>
> ```
> new-model
>
> ```
>
>
>
> Sau khi chạy tiện ích xong bạn có thể gõ 'localhost/newModel' vào trình duyệt để thử ngay.
>
> Muốn tham khảo đủ tính năng, bạn cần làm 2 việc chính để sử dụng như MVC-framework:
>
> - 1- Đến thư mục src/domain/NEW\_MODEL và thiết kế bổ sung ORM cho file NEW\_MODEL.php
> - 2- Tạo bảng tương thích với NEW\_MODEL.
>
> Bạn không cần phải quan tâm đến router, chỉ code các action (Đến thư mục src/application/actions/NEW\_MODEL để thiết kế các action, các setup route cho từng action sẽ được đặt ngay trước class như trong mẫu) cho từng model và đặt tên như qui định ở dưới.

- Qui định bắt buộc:
    - Cấu trúc thư mục như slim4 gốc (xem mẫu model Product)
    - Tên các chức năng của Product phải có chữ đầu tiên là viết in hoa và nối phía sau là Action (ex: ListAction.php, RowAction.php, ...)

*Chạy thử:* Bạn có thể gõ các địa chỉ thử nghiệm như dưới.

- Liệt kê toàn bộ bảng product:

    - localhost/product/list
- Xem thông tin một hảng (có id=2):

    - localhost/product/row/2
- Xem product/index:

    - localhost/product
- v.v...

##### Cấu hình:

[](#cấu-hình)

- **Chèn vào \\public\\index.php:**

    - Khai báo thêm use:

        > use \\Invoker\\CallableResolver as InvokerCallableResolver; use Slim\\Interfaces\\CallableResolverInterface;
    - Chèn kết nối database: (sau đoạn)

        > // Set up repositories $repositories = require **DIR** . '/../app/repositories.php'; $repositories($containerBuilder);

        ```

         // Set up PDO and doctrine-entity
         $diConn = require __DIR__ . '/../app/di-conn.php';
         $diConn($containerBuilder);

        ```
    - Chèn DI-Bridge (Không dùng slim-bridge vì lỗi với tham số url): (thay thế sau đoạn)

        > // Instantiate the app //from... AppFactory::setContainer($container); //from... $app = AppFactory::create();

        ```

         $container->set(CallableResolverInterface::class, new InvokerCallableResolver($container)); //??
         $app = AppFactory::createFromContainer($container);
         $container->set(App::class, $app);

        ```
- **Sửa đổi \\App\\Settings\\route.php:**

    - Chèn auto-route: (sau đoạn)

    > $app-&gt;options('/{routes:.\*}', function (Request $request, Response $response) { // CORS Pre-Flight OPTIONS Request Handler return $response; });

    *Ghi chú:* Có thể rào lại toàn bộ $app-&gt;get(...) của bản gốc và chỉ dùng duy nhất 1 cấu hình route như dưới.

    ```

     $autoController = require  '..\src\Base\AutoController.php';
     $aUri = explode('/',$_SERVER['REQUEST_URI'] . '/');
     $autoController($app, $aUri[1], $aUri[2]);

    ```

> *Chú thich:* Các tính năng đang trong quá trình thiết kế do vậy cần sự đóng góp của mọi người. Thanks!

*Tác giả: Phi-Hùng -  - Readme v.1.0*

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/e8467443a275c0c04a9730ced053bc9c922a3667e58bff388e04e68c68036069?d=identicon)[PhiHung908](/maintainers/PhiHung908)

---

Top Contributors

[![PhiHung908](https://avatars.githubusercontent.com/u/167226939?v=4)](https://github.com/PhiHung908 "PhiHung908 (1 commits)")

### Embed Badge

![Health badge](/badges/slim4-mod-auto-route-conn/health.svg)

```
[![Health](https://phpackages.com/badges/slim4-mod-auto-route-conn/health.svg)](https://phpackages.com/packages/slim4-mod-auto-route-conn)
```

###  Alternatives

[laravel/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M191](/packages/laravel-telescope)[spiral/roadrunner

RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins

8.4k12.2M84](/packages/spiral-roadrunner)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M256](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

708181.8M592](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
