Skip to content

colopl/pskel

Repository files navigation

Pskel

日本語

A simple, fast, and convenient PHP Extension skeleton project

Overview

Pskel is a skeleton project designed to streamline the development of PHP extensions.

It provides a comprehensive toolkit that covers everything from setting up the development environment to continuous integration.

Key Features

🚀 Rapid Environment Setup

🛠 Advanced Debugging and Analysis Tools

  • Support for Valgrind and LLVM Sanitizer
  • Integration of external services via docker compose

🧪 Comprehensive Testing Environment

  • Testing across various PHP builds (NTS, ZTS, DEBUG, etc.)
  • Easy task execution with the pskel command

🔄 Continuous Integration with GitHub Actions

  • Standard tests (NTS, ZTS)
  • Memory leak checks
  • LLVM Sanitizer inspections
  • Code coverage analysis
  • Support for testing on various OS platforms:
    • Linux
    • macOS
    • Windows

☁️ Cloud Development Environment

Setup Instructions

Preparing for Local Development

  1. Install Visual Studio Code
  2. Install Docker / Docker Compose compatible runtime
  3. Create a repository using colopl/pskel as a template
  4. Clone locally, open in VSCode, and select "Open in Container"

Preparing for Development in GitHub Codespaces

  1. Create a repository using colopl/pskel as a template
  2. Create a new Codespace from the WebUI under <> Code -> Codespaces

Creating the Skeleton

After launching the development environment, run the following command in the terminal:

$ pskel init <YOUR_EXTENSION_NAME>

This will create an extension template in the /ext directory.

Additional options available in ext_skel.php are also supported.

Testing

Testing the Extension

We provide a convenient testing environment using the pskel command:

$ pskel test          # Test with standard PHP
$ pskel test debug    # Test with debug build PHP
$ pskel test gcov     # Generate code coverage using GCC Gcov
$ pskel test valgrind # Memory check using Valgrind
$ pskel test msan     # Check using LLVM MemorySanitizer
$ pskel test asan     # Check using LLVM AddressSanitizer
$ pskel test ubsan    # Check using LLVM UndefinedBehaviorSanitizer

Testing Integration with External Services

You can integrate external services into your development environment by editing the compose.yaml file. A sample MySQL configuration is included in compose.yaml (commented out).

Code Coverage

Checking Coverage in Development Environment

You can check the code coverage using lcov with the pskel command:

$ pskel coverage
~~~
Reading tracefile /workspaces/pskel/ext/lcov.info
            |Lines       |Functions  |Branches
Filename    |Rate     Num|Rate    Num|Rate     Num
==================================================
[/workspaces/pskel/ext/]
bongo.c     |75.0%     20|80.0%     5|    -      0
==================================================
      Total:|75.0%     20|80.0%     5|    -      0

Checking Coverage in GitHub Actions

You can use octocov to check coverage information in GitHub Actions.

When you create a Pull Request, octocov automatically comments with the coverage information.

Checking Coverage in GitHub Pages

By enabling GitHub Pages for your repository and enabling Actions deployment, you can view code coverage generated by lcov and genhtml commands on GitHub Pages.

Frequently Asked Questions

Q: Can I use debuggers like gdb or lldb?

A: Yes. All development tools are pre-installed. For example, to use gdb:

$ gdb --args <php_binary> -dextension=./modules/your_extension_name.so example.php

Q: Can I use editors other than Visual Studio Code?

A: While not recommended, you can use any editor that supports Development Containers.

Q: What if I have other questions?

A: Feel free to ask on GitHub or X (formerly Twitter).

License

PHP License 3.01

About

Pskel - PHP Extension Skeleton

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •