Logo partez


A simple & fast PHP starter kit for web app.

πŸ› Report Bug | See on Packagist πŸ“¦οΈ

Total Downloads Latest Stable Version License

partez is a PHP starter kit designed to help developers quickly set up and manage a PHP web application. It includes robust backend support with streamlined front-end automation via bricolo, a JS package that compiles assets, serves your app, and provides live reloading for a smooth development workflow.

Home

  1. Getting Started
  2. How It Works
  3. Bricolo JS Automation
  4. Built With
  5. Contributing
  6. Contact

Getting started

Requirements

Installation and Setup

  1. Project Setup: Create a new folder for your project and open a terminal in it.

  2. Install the PHP Framework: Run this command to install partez and its dependencies:

composer create-project abollinger/partez .
  1. Create a .env File: If not automatically created, create a .env file at the project root. You can use .env.example as a reference.

  2. Automatic Front-End Setup with bricolo: bricolo is automatically installed via npm as part of the post-create command in composer.json. This includes asset compilation and live reloading. If you run the create-project command with --no-script options, you should run npm install to make sure that bricolo will be available.

  3. Run the Development Server: Start the server with the command below to view the app in your browser at localhost:1234 (the port may change according to the other ports already in use on your machine. Please check the log in the console):

composer serve

How it works

Configuration

  1. HTML Customization: Modify the HTML layout in src/views/Layout.twig to adjust the document head.

  2. Routing: Routes are automatically derived from controllers in src/Controllers using specific annotations (see below).

The Router

Define routes in src/Controllers files using PHP annotations:

/**
 * @Route("/", name="Home", auth=false)
 */

The Pages

Controllers in src/Controllers extend the main controller (Abstract/Controller.php). The init() method call renderPage("Page.twig") to render the Twig template. Each page extends the main layout in src/views/Layout.twig.

The Public Folder

The public directory houses index.php, as well as js, css and images folders, which can be customized freely.

The API

A basic API is available in api/ and runs on a MySQL database.

Bricolo JS Automation

The Partez PHP framework includes bricolo as an automation tool for front-end tasks, so you can focus on development without needing to handle asset compilation or live reloading setup yourself. bricolo is installed automatically during setup, and it's already configured with a bricoloconfig.json file that defines custom settings to integrate with this project.

You can find more information on the npm of the bricolo (js) package.

Bricolo JS Configuration

bricolo is automatically installed within the project and configured with the file bricoloconfig.json:

{
    "phpServer": {
        "port": 8080,
        "command": "composer serve p={port}"
    },
    "jsBuild": {
        "entry": "assets/js/main.ts",
        "output": "public/js/bundle.js"
    },
    "sassBuild": {
        "entry": "assets/css/main.scss",
        "output": "public/css/style.min.css"
    },
    "watch": {
        "directories": [
            "src/**/*.php",
            "src/**/*.yaml",
            "view/**/*.twig",
            "public/**/*.css",
            "public/**/*.js",
            "public/**/*.svg"
        ]
    },
    "server": {
        "port": 1234
    }
}

Configuration Overview

Usage

After creating the project, you can simply start the bricolo automation and server:

npm run serve

Or, if you prefer, use the command directly:

npx bricolo serve

This command will:

  1. Start the PHP server on port 8080.
  2. Compile and watch for changes in JavaScript and Sass files.
  3. Automatically reload the browser at localhost:1234 whenever changes are detected in watched files.

Build with

The basic structure is:

.
β”œβ”€β”€ api/
β”‚   β”œβ”€β”€ Abstract/ (Basic logic of the api)
β”‚   β”œβ”€β”€ Config/ (Configuration files)
β”‚   β”œβ”€β”€ Controllers/
β”‚   β”‚   └── [Controllers, typo is <Name>Controller.php]
β”‚   β”œβ”€β”€ Models/
β”‚   β”‚   └── [Models, typo is <Name>Model.php]
β”‚   β”œβ”€β”€ Provider/ (Providers logic like Database or any other resources provider)
β”‚   β”œβ”€β”€ Router/ (main router logic for the api)
β”‚   β”œβ”€β”€ View/ (set up a standardized response for every API request)
β”‚   └── Starter.php
β”œβ”€β”€ assets/
β”‚   β”œβ”€β”€ css/ (Contains scss files that will be compiled into css in the public/css folder, based on bricolo js automation)
β”‚   └── js/ (Contains typescript scripts that will be compiled into js in the public/js folder, based on bricolo js automation)
β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ css/
β”‚   β”œβ”€β”€ images/
β”‚   β”œβ”€β”€ js/
β”‚   └── index.php
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ Abstract/ (Basic logic of the app)
β”‚   β”œβ”€β”€ App/ (Starter of the app)
β”‚   β”œβ”€β”€ Config/ (Some configuration files like Bootstrap or Session)
β”‚   β”œβ”€β”€ Controllers/
β”‚   β”‚   └── [Controllers, typo is <Name>Controller.php]
β”‚   └── Router/ (Contains main Router logic)
β”œβ”€β”€ views/ (Contain Twig templates for your app)
└── .env

Contributing

We welcome contributions! Here’s how to contribute:

Contact

If you have any questions, feel free to reach out:

Antoine Bollinger - LinkedIn - antoine.bollinger@gmail.com

You can talk to me in πŸ‡«πŸ‡·, πŸ‡§πŸ‡· or πŸ‡¬πŸ‡§.