Search by

sitthichok / pgtest

sitthichokt

ทดสอบสร้าง libary

v1.0.0 2026-07-24 06:02 UTC

This package is auto-updated.

Last update: 2026-08-24 08:49:45 UTC


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/, not app/.
  • DevKit templates default to CI4 app layout (app/). For this library, phpunit.xml.dist uses vendor/autoload.php and includes ./src/.
  • DevKit helps with code quality tooling; it does not scaffold or publish the package.

License

MIT