abollinger / partez
A simple & fast PHP starter kit for web app
Installs: 71
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
Requires
- php: ^8.1
- abollinger/bricolo: ^1.6
- abollinger/helpers: ^1.2
- abollinger/router: ^1.1
- abollinger/session: ^1.2
- twig/html-extra: ^3.8
- twig/intl-extra: ^3.8
- twig/twig: ^3.8
- vlucas/phpdotenv: ^5.6
- dev-master
- v2.8.6
- v2.8.5
- v2.8.4
- v2.8.3
- v2.8.2
- v2.8.1
- v2.8.0
- v2.7.9
- v2.7.8
- v2.7.7
- v2.7.6
- v2.7.5
- v2.7.4
- v2.7.3
- v2.7.2
- v2.7.1
- v2.7.0
- v2.6.9
- v2.6.8
- v2.6.4
- v2.6.3
- v2.6.2
- v2.6.1
- v2.6.0
- v2.5.9
- v2.5.8
- v2.5.7
- v2.5.6
- 2.5.5
- v2.5.4
- v2.5.3
- v2.5.2
- v2.5.1
- v2.5.0
- v2.4.9
- v2.4.8
- v2.4.7
- v2.4.6
- v2.4.5
- v2.4.2
- v2.4.1
- v2.4.0
- v2.3.0
- v2.2.8
- v2.2.7
- v2.2.5
- v2.2.4
- v2.2.3
- v2.2.2
- v2.2.1
- v2.2.0
- v2.1.0
- v2.0.0
- v1.3.0
- v1.2.4
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-release
This package is auto-updated.
Last update: 2024-12-02 10:52:36 UTC
README
A simple & fast PHP starter kit for web app.
π Report Bug | See on Packagist π¦οΈ
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.
Getting started
Requirements
- Composer for backend dependency management.
- Node.js (v12 or higher) and npm for
bricolo
to enable asset compilation and live reloading.
Installation and Setup
-
Project Setup: Create a new folder for your project and open a terminal in it.
-
Install the PHP Framework: Run this command to install
partez
and its dependencies:
composer create-project abollinger/partez .
-
Create a
.env
File: If not automatically created, create a.env
file at the project root. You can use .env.example as a reference. -
Automatic Front-End Setup with
bricolo
:bricolo
is automatically installed via npm as part of the post-create command incomposer.json
. This includes asset compilation and live reloading. If you run the create-project command with--no-script
options, you should runnpm install
to make sure thatbricolo
will be available. -
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
-
HTML Customization: Modify the HTML layout in
src/views/Layout.twig
to adjust the document head. -
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) */
- URI (
"/"
) is mandatory. - Name (
name="Home"
) specifies the route's name. - Authentification (
auth=false
) restricts the access if set totrue
(default isfalse
).
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
-
PHP Server: The PHP server will run on port 8080 using the command
composer serve p={port}
. -
Asset Compilation:
- JavaScript: Compiles assets/js/main.ts into a bundle at public/js/bundle.js.
- CSS: Compiles assets/css/main.scss into a minified CSS file at public/css/style.min.css.
-
File Watching:
bricolo
monitors files in specified directories (src/**/*.php
,view/**/*.twig
,public/**/*.css
, etc.) for changes, which will trigger asset compilation and live browser reload.
-
Live Reload Server: The development server is set to run on port 1234 for hot reloading.
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:
- Start the PHP server on port 8080.
- Compile and watch for changes in JavaScript and Sass files.
- Automatically reload the browser at localhost:1234 whenever changes are detected in watched files.
Build with
- This kit is build in PHP, using as much as possible the MVC pattern. We use the Twig template engine to generate the pages.
- Style is now powered by Bootstrap v5.2, using the simple CDN link.
- You can add JS scripts in the public folder or wherever you want, as mentioned earlier.
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:
- Fork the project.
- Create your feature branch:
git checkout -b features/Myfeature
. - Commit your changes:
git commit -m "β¨ Introducing Myfeature!"
. - Push to Github:
git push origin features/Myfeature
. - Open a Pull Request.
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 π¬π§.