abollinger / partez
A simple & fast PHP starter kit for web app
Installs: 42
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
Requires
- php: ^8.1
- abollinger/bricolo: ^1.3
- abollinger/helpers: ^1.2
- abollinger/router: ^1.0
- abollinger/session: ^1.1
- twig/html-extra: ^3.8
- twig/intl-extra: ^3.8
- twig/twig: ^3.8
- vlucas/phpdotenv: ^5.6
- dev-master
- 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
This package is auto-updated.
Last update: 2024-10-08 09:31:28 UTC
README
A simple & fast PHP starter kit for web app.
🐛 Report Bug | See on Packagist 📦️
This kit is intended to help developpers to quickly create a simple PHP app.
This project is published on Packagist so you can create a new project based on it.
Table of Contents
Getting started
Requirements
All you need is Composer to create the project run the server (in developpement mode).
Steps
-
First create a new folder for your project and open a terminal in it
-
Run the following command. This will create all the necessaries files and install the dependencies of the project:
composer create-project abollinger/partez .
-
Then you will have to create a
.env
file at the root of your project. This is supposed to be done automatically but if it is not, you can use the.env.example
to see what the .env can contain at this moment. -
Finally run this simple command:
composer serve
and then open your browser at localhost:1234 to see the result (the port may change according to the other ports already in use on your machine. Please check the log in the console).
How it works
Configuration
-
You may want to customized the HTML head of you app. Please go the
src/view/layout.html.twig
file and make the change you need. -
Regarding the router configuration, it is described below.
The router
Routes are automatically derived from Controller files contained in the src/Controller
folder.
For this to work, each Controller must be block-commented in the following way:
/** * @Route("/", name="Home", auth=false) */
The first element, "/"
is the URI through which the page will be accessible. It's mandatory.
The second element, name="Home"
is the name of the page. It is also mandatory.
Finally, the third element allow you to restrict access to the page to logged in users, througt the $this->session->isLoggedAndAuthorized(true)
.
The pages
Pages are rendered by the controller in the src/Controller
path. This controller must be an extension of the main controller define in Abstract/Controller.php
.
In the page's controller you must define the init()
method that will call the renderView("page.html.twig")
method which render the twig template.
The twig templates are localized in the src/view
at the root of the project. Basic twig layout is defined as src/view/layout.html.twig
and each page's twig template extends this layout.
The public folder
The public
directory contains the index.php entry point, basics js, css and images folder. Please feel free to customized this part.
The API
A basic API is available in the api/
folder. This API is powered by a database running on MySQL.
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) │ ├── Controller/ │ │ └── [Controllers, typo is <Name>Controller.php] │ ├── Model/ │ │ └── [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 ├── 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) │ ├── Controller/ │ │ └── [Controllers, typo is <Name>Controller.php] │ ├── Router/ (Contains main Router logic) │ └── view/ (Contain Twig templates for your app) └── .env
Contributing
Any contributions you could make will be amazingly appreciated! Please follow this steps to submit your ideas:
- Fork the project
- Create your feature branch widh
git checkout -b features/Myfeature
- Commit your work
git commit -m "✨ Introducing Myfeature!"
- Push
git push origin features/Myfeature
- Open a Pull Request
We'll make a review of your work and merge it to the master branch if everything's OK. Do not hesitate, every little contribution is a great way to make this starter kit getting bigger!
Contact
If you have any question about this package, how to install, to use or to improve, feel free to contact me:
Antoine Bollinger - LinkedIn - antoine.bollinger@gmail.com
You can talk to me in 🇫🇷, 🇧🇷 or 🇬🇧.