PHPackages                             blakvghost/juste - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. blakvghost/juste

ActiveLibrary

blakvghost/juste
================

Juste is the Core of Project Bravo, my personal PHP MVC framework, it essentially ensures the understanding of Models, Controller, the basic template engine.It also manages the Routing, the middlewares, the database, and especially my super nice homemade mini ORM without forgetting the easy sending of emails.

2.0.2(2y ago)43711MITPHPPHP ^8.0

Since Jul 8Pushed 2y ago1 watchersCompare

[ Source](https://github.com/BlakvGhost/Juste)[ Packagist](https://packagist.org/packages/blakvghost/juste)[ RSS](/packages/blakvghost-juste/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (2)Versions (4)Used By (1)

Juste
=====

[](#juste)

Juste is the Core of Project [Bravo, my personal PHP MVC framework](https://github.com/BlakvGhost/Bravo), it essentially ensures the understanding of Models, Controller, the basic template engine. It also manages the Routing, the middlewares, the database, and especially my super nice homemade mini ORM without forgetting the easy sending of emails.

[![Packagist Version (custom server)](https://camo.githubusercontent.com/3847db89386252a114d60afe08782a25a549fe0e21cc531e739dc6bafdd3b8df/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f426c616b7667686f73742f4a757374653f6c6162656c3d737461626c65)](https://camo.githubusercontent.com/3847db89386252a114d60afe08782a25a549fe0e21cc531e739dc6bafdd3b8df/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f426c616b7667686f73742f4a757374653f6c6162656c3d737461626c65)[![Packagist Version (custom server)](https://camo.githubusercontent.com/b8c725d7b1aca40f563ebd9e39369844978dc478c657f400e28d042d033fd273/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f426c616b7667686f73742f4a757374653f6c6162656c3d4c6963656e6365)](https://camo.githubusercontent.com/b8c725d7b1aca40f563ebd9e39369844978dc478c657f400e28d042d033fd273/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f426c616b7667686f73742f4a757374653f6c6162656c3d4c6963656e6365)[![Packagist Version (custom server)](https://camo.githubusercontent.com/cef895e95340c22173a9cab7eefb7fc990b3d3e6ff7c4a56a6d3e3571b0a4c25/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f426c616b7667686f73742f4a757374653f6c6162656c3d646f776e6c6f6164)](https://camo.githubusercontent.com/cef895e95340c22173a9cab7eefb7fc990b3d3e6ff7c4a56a6d3e3571b0a4c25/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f426c616b7667686f73742f4a757374653f6c6162656c3d646f776e6c6f6164)

Documentation:
--------------

[](#documentation)

Documentation for Bravo is currently being prepared and will be available soon. Stay tuned for updates!

How to use:
-----------

[](#how-to-use)

To see an example of using Bravo, you can refer to the [Bravo](https://github.com/BlakvGhost/Bravo) project. It serves as a demonstration project and will have official documentation soon.

Installation
------------

[](#installation)

To install Juste, you can follow these steps:

1. Require the package using Composer by running the following command:

    ```
    composer require blakvghost/juste
    ```
2. Once the package is installed, you can start integrating Juste into your PHP project.

Requirements
------------

[](#requirements)

- PHP 8.0 or higher

Please note that Juste requires the following packages as dependencies: `symfony/dotenv (version 6.2 or higher)` and `symfony/mailer (version 6.2 or higher)`. These dependencies will be automatically installed when you install Juste using Composer.

Features
--------

[](#features)

- Models: Define your data models and interact with the database using Juste's mini ORM.
- Controllers: Implement your application's logic and handle user requests.
- Routing: Define routes and map them to specific controller actions.
- Middlewares: Apply custom logic to incoming requests and modify the request or response.
- Database: Easily perform database operations using Juste's ORM.
- Template Engine: Utilize the basic template engine provided by Juste for rendering views.
- Email Sending: Simplify the process of sending emails within your application.

Utility Functions
-----------------

[](#utility-functions)

Juste provides some utility functions that you can use in your application:

### Common Facade

[](#common-facade)

The `Common` facade includes various utility functions:

- `posts()`: Returns an array with all the contents of the global $\_POST variable escaped with htmlentities().
- `server(string $key)`: Returns the value of the given key from the global $\_SERVER array.
- `input(string $key, string $default = '')`: Returns the value of the given key from either the global $\_POST or $\_GET variables, with the option to specify a default value if the key is not set.
- `file(string $key)`: Returns the file uploaded with the given key from the global $\_FILES variable or redirects back to the previous page with an error message if no file was uploaded.
- `redirectTo(string $path = '')`: Redirects the user to the given path using the header() function.
- `redirecTo(string $path = '')`: Redirects the user to the given path using the header() function (typo in the code, corrected as redirectTo).
- `sanitize_post(string $key, bool $strict = true)`: Returns the sanitized value of the given key from the global $\_POST variable, with the option to validate that the key exists and is not empty.
- `back()`: Redirects the user back to the previous page.
- `with(string $message, $key = 'error')`: Sets a message on the session with the given key (defaulting to 'error').
- `json(array $data)`: Returns a JSON-encoded string of the given array.
- `user($attr = false)`: Returns current authenticated user information or an empty array if not authenticated.
- `store_media($file, string $newFileName)`: Stores a media file with the given name and returns the file - path or redirects back with an error message if the file upload fails.
- `setDataOnSession($key, $message)`: Sets data on the session with the given key and message.
- `getDataOnSession($key)`: Retrieves data from the session using the given key.
- `setErrorMessageOnSession($message)`: Sets an error message on the session.
- `dd($value, ...$args)`: Displays the value and additional arguments using var\_dump() within a &lt;\\pre&gt; tag and exits.
- `route(string $alias)`: Returns the route URL for a given alias.
- `redirect(string $alias)`: Redirects the user to the route URL for a given alias.

### Controller Facade

[](#controller-facade)

The Controller facade includes some useful functions for controller classes:

- `render($view, $title = '', $context = null)`: Returns the full view path or a 404 view path with the context data. It checks whether the file exists and returns an appropriate response.
- `html(string $html)`: Returns an array with full HTML code, useful for returning HTML responses.
- `can(array $user_type = null, string $column = 'roles')`: Checks whether the user is authenticated and has the specified user types/roles. Redirects back with an error message if the user doesn't have the required role.
- `mustAuthenticate(bool $statut = true)`: Checks whether the user is authenticated based on the provided status. Redirects with an error message if the authentication status is not met.

Usage Examples
--------------

[](#usage-examples)

### Routing

[](#routing)

```
