imgnd/arti

A lightweight micro php framework

Maintainers

Details

gitlab.com/imgnd/arti

Homepage

Source

Installs: 21

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Forks: 0

Type:package

0.1.3 2022-08-25 20:35 UTC

This package is not auto-updated.

Last update: 2024-05-17 04:30:26 UTC


README

Latest Stable Version Total Downloads License php

A lightweight micro php framework

Installation

Install using composer require imgnd/arti.\ Copy all files and folders from "vendor/imgnd/arti/files" into root of your project and remove ".example" from the names.\ Fill in the environment settings in ".env". Read the instructions for linking urls to functions in "routes/web.php".\ Create three directories named "models", "views" and "controllers". The files in these folders will load automatic.\ Include "vendor/autoload.php" in the "index.php" of your project to use the framework structure and functions.\ New projects can also simply be made with the "imgnd/arti-project" package.

Usage

Put your classes in the "controllers" folder. In "routes.php" you can set which method must be called on an url.\ All files for getting data from and set into the database can be placed in the "models" folder. Use the shortcut DB::class for rapid development.\ The views can be made follow the Blade Template Engine standards and are rendered with the standalone version BladeOne.

Routing

For each accessible uri create a routing link to set which method is needed to call.\ Put the full link without domain name and including leading slash as first parameter.\ Trailing slashes will automatic be removed by default, this can be changed in ".htaccess".\ In the url will parts between curly brackets be convert to parameters.\ Example: on visiting "/users/42/profile" will use "/users/{id}/profile" as link and set "42" as value for the variable $id.\ The second parameter must be a callable action or a string containing the Class@method.\ When using a string as second parameter can an optional third parameter be added. This must be an array.\ The parameters from curly brackets will be merged with these and passed to the method.\ Adding default parameters to urls can be helpful on setting or checking rights or roles for users.

Helpful functions

This lightweight framework contains some helpful functions for rapid development.

See the Imgnd\Arti\Helper class for some supportive methods. Some are directly callable as php functions, these are defined in functions.php

  • The dump() function is easy for development. This function prints a var_dump() within <pre> tags, so the data is clearly readable.
  • All get, post and session data is readable as object in the super global variables $get, $post and $session.
  • Get an environment setting with the env() function.
  • A full storage path can be retrieved with the file_path() function.
  • The full url to a file can be generated by the public_url() function.
  • With View::get() you can get the html of a template part. With View::render() you display a full template.
  • Use the DB::class functions to generate and execute SQL queries.
  • See the "files/migrations.sql.example" file for queries to set up your database.

License

The Arti framework is open-sourced software licensed under the MIT license.