sitthichok / pgtest
ทดสอบสร้าง libary
v1.0.0
2026-07-24 06:02 UTC
Requires
- codeigniter4/framework: ^4.7
Requires (Dev)
- codeigniter4/devkit: ^1.3
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Learning package for building a CodeIgniter 4 library with CodeIgniter DevKit.
โปรเจกต์นี้ใช้ฝึกสร้าง PHP library / Composer package สำหรับนำไปใช้กับแอป CodeIgniter 4
Requirements
- PHP 8.2+
- Composer
- CodeIgniter 4.7+
Installation
From Packagist
composer require sitthichok/pgtest
หรือระบุเวอร์ชัน:
composer require sitthichok/pgtest:^1.0
Local path (development)
ใน composer.json ของแอป CI4:
{
"repositories": [
{
"type": "path",
"url": "D:/webiis/Mypackages",
"options": {
"symlink": true
}
}
]
}
แล้วรัน:
composer require sitthichok/pgtest:@dev
Private GitHub (VCS)
สำหรับแชร์ในทีมโดยไม่ขึ้น Packagist แบบสาธารณะ ดูรายละเอียดใน เอกสาร-GitHub-Private-Composer-VCS.txt
Usage
use Sitthichok\Pgtest\Hello; $hello = new Hello(); echo $hello->greet(); // Hello, World! echo $hello->greet('CI4'); // Hello, CI4!
ตัวอย่างใน CodeIgniter Controller:
<?php namespace App\Controllers; use Sitthichok\Pgtest\Hello; class Home extends BaseController { public function index() { $hello = new Hello(); echo $hello->greet('CI4'); } }
Project structure
src/ Library source code (PSR-4)
tests/ PHPUnit tests
phpunit.xml.dist PHPUnit config (library-oriented)
composer.json Package definition
Namespace mapping:
Sitthichok\Pgtest\ → src/
Development
Install dependencies:
composer install
Run tests:
vendor/bin/phpunit
Run tests with coverage (requires Xdebug with coverage mode):
vendor/bin/phpunit --coverage-text
This project uses codeigniter4/devkit for development tooling (PHPUnit, PHPStan, PHP CS Fixer, Rector, etc.).
Notes
- This package is a library, so source code lives in
src/, notapp/. - DevKit templates default to CI4 app layout (
app/). For this library,phpunit.xml.distusesvendor/autoload.phpand includes./src/. - DevKit helps with code quality tooling; it does not scaffold or publish the package.
License
MIT