PHPackages                             slim-mvc/core - 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. slim-mvc/core

ActiveCore[Framework](/categories/framework)

slim-mvc/core
=============

Slim4-MVC tiny and faster MVC framework for PHP

v1.1.0.0-dev(1y ago)031MITPHP

Since Aug 7Pushed 1y ago1 watchersCompare

[ Source](https://github.com/PhiHung908/slimMVC-core)[ Packagist](https://packagist.org/packages/slim-mvc/core)[ Docs](https://github.com/PhiHung908)[ RSS](/packages/slim-mvc-core/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

Cập nhật Core - Slim4-MVC
-------------------------

[](#cập-nhật-core---slim4-mvc)

Cần cài đặt phiên bản đầy đủ trong lần đầu tiên.

```
composer create-project slim4-mod/mvc:"dev-master" ./slimMVC

```

(Chỉ cần cài đặt cập nhật khi có phiên bản mới)

---

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

---

Slim-MVC tiny and faster MVC framework for PHP

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

> *Đặc biệt:*
>
> - Có thể chạy nhiều website như từng module riêng lẻ trên một framework slimMVC duy nhấ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.
> - View mặc định là PHP, bạn có thể dùng Smary (đặt phần mở rộng của view là .tpl) hoặc Twig (.twig) - Hệ thống sẽ nạp code động (lazy-dynamic load) khi bạn sử dụng một trong các loại kết xuất "view".

---

**Cài đặt:**

```
* Lệnh cài đặt cập nhật: "dev-master" hoặc phiên bản mới nhất

composer require slim-mvc/core "dev-master"
```

### HƯỚNG DẪN CẤU HÌNH HỆ THỐNG và VÀI ĐIỀU CƠ BẢN VỀ FRAMEWORK NÀY

[](#hướng-dẫn-cấu-hình-hệ-thống-và-vài-điều-cơ-bản-về-framework-này)

##### \* Cấu hình Apache:

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

**httpd.conf:**

```
Define SRVROOT "D:/Path-to/Apache24"
Define SRVROOTV "${SRVROOT}/../www"

```

**httpd-vhosts.conf:**

*localhost*

```

	Options Indexes FollowSymLinks
	AllowOverride All
	Require all granted

	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteRule ^ index.php [QSA,L]
	FallbackResource /index.php

	RewriteEngine on
	RewriteRule ^/sslim/(.*) /sslim/index.php/$1 [QSA,L]

	AddDefaultCharset UTF-8
	DocumentRoot "${SRVROOTV}"
	ServerName localhost
	ErrorLog "logs/localhost-error.log"
	CustomLog "logs/localhost-access.log" common

```

---

*subdir:*

```
Alias /sslim "${SRVROOTV}/slimMVC/src/web"

	ServerName localhost
	ErrorLog "logs/localhost-error.log"
	CustomLog "logs/localhost-access.log" common

	DocumentRoot "${SRVROOT}/slimMVC/src/web"

		Options Indexes FollowSymLinks
		AllowOverride None
		Require all granted

		RewriteCond %{REQUEST_FILENAME} !-f
		RewriteCond %{REQUEST_FILENAME} !-d
		RewriteRule ^ index.php [QSA,L]
		FallbackResource /index.php

	ServerName slim.local #cần khai báo hosts trong window: 127.0.0.1 slim.local
	ErrorLog "logs/slimMVC-error.log"
	CustomLog "logs/slimMVC-access.log" common

	DocumentRoot "${SRVROOTV}/slimMVC/src/web"

```

\--

> **Nếu bạn cài đăt từ composer thì phần dưới đây đã được thiết lập sẵn**
>
> **Quan trọng:** để ngăn truy xuất các thư mục con trong slimMVC, cần tạo slimMVC/.htacces với 1 dòng sau:
>
> Require all denied
>
> Đồng thời để "mở lại" chức năng truy xuất web, bạn cần tạo file .htacces trước thư mục "web-root" (ở ví dụ trên là thư mục src/.htacces) có 3 dòng sau:
>
> RewriteEngine on RewriteRule ^$ web/ \[L\] RewriteRule (.\*) web/$1 \[L\]

> **Test:**
>
> or
>

##### Ảnh cấu trúc thư mục:

[](#ảnh-cấu-trúc-thư-mục)

[![common/docs/dir-struct.PNG](common/docs/dir-struct.PNG "Cấu trúc thư mục...")](common/docs/dir-struct.PNG)

##### 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/NEW\_MODEL' 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/models/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.

- Qui định bắt buộc:
    - Cấu trúc thư mục như slim4 mẫu đang có. Tất cả thư mục là chữ thường, các file (class) là chữ cái đầu in hoa.
    - 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...

### HƯỚNG DẪN MỞ RỘNG

[](#hướng-dẫn-mở-rộng)

- **Tách website thành từng module:**

> Bạn có thể mở nhiều web site trên một framework slimMVC, hãy thực hiện các bước:
>
> 1- Khai báo tên module trong file common/config/prs4-alias.php (mẫu như dòng admin đã có trong file)
>
> 2- Copy thư mục template-web (hoặc backend, frontend hoặc thư mục nào đó của bạn) thành một bản mới.
>
> 3- Đổi tên thư mục vừa copy thành tên giống module đã khai báo ở bước 1.
>
> Sau khi hoàn thành, bạn có thể gõ vào *localhost/**admin**/product/list*
> (**admin** là module đã có sẵn, hãy thay nó bằng tên module của bạn)

- **Assets cho css, js và image -** Hệ thống sẽ tự nạp assets theo một trong 2 cách sau:

> a- Nạp class trực tiếp trong file action nếu bạn có khai báo constructor và class (xem mẫu product/listAction.php)
>
> b- Nạp từ file xxx\\controllers\\xxx\\auto\_gen\\Asset.php
>
> - Khai báo AssetClass cho hai cách trên là giống nhau, hãy tham khảo mẫu ListAction và RowAction trong .../product)

---

> *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.2*

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity25

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

649d ago

### 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)")

---

Tags

slimslim routeslim connectslim conn dbslim4 routeslim4 connslim MVC framework

### Embed Badge

![Health badge](/badges/slim-mvc-core/health.svg)

```
[![Health](https://phpackages.com/badges/slim-mvc-core/health.svg)](https://phpackages.com/packages/slim-mvc-core)
```

###  Alternatives

[slim/twig-view

Slim Framework 4 view helper built on top of the Twig 3 templating component

3708.0M210](/packages/slim-twig-view)[slim/php-view

Render PHP view scripts into a PSR-7 Response object.

2739.7M95](/packages/slim-php-view)[slim/csrf

Slim Framework 4 CSRF protection PSR-15 middleware

3512.1M94](/packages/slim-csrf)[slim/flash

Slim Framework Flash message service provider

1522.2M99](/packages/slim-flash)[slim/http-cache

Slim Framework HTTP cache middleware and service provider

1242.9M27](/packages/slim-http-cache)[davidepastore/slim-validation

A slim middleware for validation based on Respect/Validation

171223.7k3](/packages/davidepastore-slim-validation)

PHPackages © 2026

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