Download the PHP package nihad1213/litephp without Composer

On this page you can find all versions of the php package nihad1213/litephp. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package litephp

LitePHP Framework

Downloads

LitePHP is a lightweight PHP framework designed for building simple and efficient APIs. It provides a straightforward CLI tool for common development tasks and a minimalist structure for rapid API development.

Installation

Get started with LitePHP using Composer:

This will install LitePHP, navigate to your new project directory, copy .env.example file to .env, genereate JWT_SECRET key and start the built-in PHP development server.

CLI Commands

LitePHP comes with a built-in command-line interface to help you manage your development workflow. Here are the available commands:

Start Development Server

Launches the PHP built-in development server at http://localhost:8000, serving files from the 'api' directory.

Generate JWT Secret Key

Creates or updates the JWT_SECRET in your .env file with a secure random key (32 bytes). This is essential for JWT-based authentication in your API.

Create a Controller

Scaffolds a new controller in the 'controllers' directory with RESTful methods (getAll, getOne, create, update, delete) and basic validation.

Create a Gateway

Scaffolds a new gateway in the 'gateways' directory. Gateways handle database operations for specific entities, providing a clean separation between controllers and database logic.

Run Database Migrations

Executes all SQL files in the 'database' directory in alphabetical order, allowing you to set up and modify your database schema.

Project Structure

Login Route Integration

To add authentication routes to your LitePHP application, you can integrate custom routes in your main index.php file. Here's an example of how to add a login route that bypasses normal authentication:

This allows you to create dedicated authentication endpoints that don't require existing authentication, such as login forms or token generation endpoints. Place this code in your main routing logic before other route processing occurs.

Key Components

Controllers

Controllers handle HTTP requests and return appropriate responses. They are responsible for:

Each controller extends the BaseController class, which provides common response methods and utilities for handling API requests.

Controller Example

Attribute-Based Routing

LitePHP uses PHP 8's attributes for routing. The #[Route] attribute defines:

Gateways

Gateways provide an abstraction layer for database operations. Each gateway:

Gateway Example

Database

The database directory stores SQL migration files that can be executed with the db:migrate command. Example migration file:

Setting Up a Complete API Endpoint

1. Create the Database Table

Create an SQL file in the database directory:

Run the migration:

2. Create a Gateway

Then, update the generated gateway file:

3. Create a Controller

Then, update the generated controller:

4. Access Your API

With your server running (php lite start), you can now access your API:

Response Methods

The BaseController class provides several methods for returning standardized API responses:

Security Features

Future Development

Contributing

Contributions are welcome! Feel free to submit issues or pull requests to help improve LitePHP.

License

[MIT License]

Created By

Nihad Namatli


All versions of litephp with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
ext-json Version *
ext-curl Version *
ext-openssl Version *
ext-pdo Version *
ext-pdo_mysql Version *
vlucas/phpdotenv Version ^5.6
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nihad1213/litephp contains the following files

Loading the files please wait ...