rpurinton/phpack

A tool to modularize and compile PHP and HTML components.

Installs: 22

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:project

1.0.7 2025-03-05 21:34 UTC

This package is auto-updated.

Last update: 2025-03-05 21:39:20 UTC


README

PHPack is a powerful tool designed to help you modularize and compile your PHP and HTML components into a single, optimized PHP file. This enhances the organization and maintainability of your web projects.

Features

  • Modular Design: Break down your web pages into reusable components for better code management.
  • JSON Configuration: Define your page structure using intuitive JSON files.
  • Automatic Compilation: Seamlessly compile your components into a single PHP file for easy deployment.

Installation

Via Composer (Recommended)

To install PHPack using Composer, simply run:

composer require rpurinton/phpack

This will make the phpack command available globally, allowing you to use it in any project.

Manual Installation

If you prefer to install PHPack manually, you can clone the repository and set up the executable:

git clone https://github.com/rpurinton/phpack.git
cd phpack
sudo chmod +x phpack && sudo cp phpack /usr/bin/

Usage

  1. Create Your Components: Organize your PHP and HTML components in the parts directory.
  2. Define Page Structure: Use JSON files in the pages directory to define the structure of your web pages.
  3. Run PHPack: Execute the phpack script to compile your pages.
phpack

Example

Directory Structure

Here's an example of how you can structure your project:

yourproject/
├── pages/
│   ├── home.json
│   ├── about.json
│   ├── contact.json
│   └── blog.json
└── parts/
    ├── head/
    │   ├── head.json
    │   ├── meta.html
    │   ├── styles.html
    │   └── scripts.html
    ├── body/
    │   ├── header.html
    │   ├── footer.html
    │   ├── content/
    │   │   ├── intro.html
    │   │   ├── features.html
    │   │   └── testimonials.html
    │   ├── about.html
    │   ├── contact.html
    │   └── blog/
    │       ├── post1.html
    │       ├── post2.html
    │       └── post3.html

JSON Example

home.json

{
    "parts": [
        "<html lang=\"en\">",
        "head/head.json",
        "<body>",
        "body/header.html",
        "body/content.json",
        "body/footer.html",
        "</body></html>"
    ]
}

The above example would result in the creation of:

yourproject/
└── public/
    ├── home.php
    ├── about.php
    ├── contact.php
    └── blog.php

You can use the public folder as your web root for your web server. A part can be either .html, .php, text/html, or another .json file that includes more parts.

License

This project is licensed under the MIT License.

Contributing

We welcome contributions from the community! Feel free to submit issues or pull requests.

Contact

For more information, please contact Russell Purinton.