Download the PHP package juneszh/alight without Composer

On this page you can find all versions of the php package juneszh/alight. 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 alight

Alight

Alight is a lightweight PHP framework that makes it easy to build high-performance RESTful web applications. It comes with built-in routing, database, caching, error handling, logging, and job scheduling. Alight focuses on the core requirements of web applications—simple by default, and extensible when you need to customize.

Alight Family

Project Description
Alight Basic framework built-in routing, database, caching, etc.
Alight-Admin A full admin panel extension based on Alight. No front-end coding required.
Alight-Project A template for beginner to easily create web applications by Alight/Alight-Admin.

Requirements

PHP 8.3+

Getting Started

Installation

Step 1: Install Composer

Don’t have Composer? Install Composer first.

Step 2: Creating Project

Using template with create-project

The project template contains common folder structure, suitable for MVC pattern, please refer to: Alight-Project.

It is easy to customize folders by modifying the configuration. But the following tutorials are based on the template configuration.

Step 3: Configuring a Web Server

Nginx example (Nginx 1.24.0, PHP 8.3.6, Ubuntu 24.04.4):

Configuration

Alight loads its application configuration from config/app.php. Alight-Project creates this file from config/app.example.php during installation. For example:

File: config/app.php

Get some items in the config

Available Configuration

See Config.php for details.

Routing

Before learning routing rules, you need to create a PHP file that stores them. The routing cache is refreshed based on the modification time of the routing file. For example:

File: config/route/web.php

File: config/app.php

By the way, the route configuration supports importing specified files for subdomains:

Basic Usage

Regular Expressions

nikic/fast-route handles all regular expressions in the routing path. See FastRoute Usage for details.

Options

Group

Customize 'any'

You can customize the methods contained in Alight\Route::any().

Disable route caching

Not recommended, but if your code requires:

Life cycle

All routing options only take effect in the current file and will be auto reset by Alight\Route::init() before the next file is imported. For example:

File: config/route/admin.php

File: config/route/web.php

Utilities

Cache-Control header

Send a Cache-Control header to control caching in browsers and shared caches (CDN) in order to optimize the speed of access to unmodified data.

Handling user authorization

We provide a simple authorization handler to manage user login status.

File: app/service/Auth.php

Request cooldown

Many times the data submitted by the user takes time to process, and we don't want to receive the same data before it's processed. So we need to set the request cooldown time. The user will receive a 429 error when requesting again within the cooldown.

Cross-Origin Resource Sharing (CORS)

When your API needs to be used for Ajax requests by a third-party website (or your project has multiple domains), you need to send a set of CORS headers. For specific reasons, please refer to: Mozilla docs.

If your website is using CDN, please use this utility carefully. To avoid request failure after the header is cached by CDN.

Database

Alight passes the 'database' configuration to the catfan/medoo directly. For specific configuration options, please refer to Medoo Get Started. For example:

File: config/app.php

Basic Usage

Alight\Database::init() is a static and single instance implementation of new Medoo\Medoo(), so it inherits all functions of Medoo(). Single instance makes each request connect to the database only once and reuse it, effectively reducing the number of database connections.

See Medoo Documentation for usage details.

Caching

Alight supports multiple cache drivers and multiple cache interfaces with symfony/cache. The configuration options dsn and option are passed to the cache adapter. See Available Cache Adapters for details. For example:

File: config/app.php

Basic Usage (PSR-16)

Like database, Alight\Cache::init() is a static and single instance implementation of the cache client to improve concurrent request performance.

PSR-6 Interface

Native Interface

Also supports memcached or redis native interfaces for using advanced caching:

More Adapter

symfony/cache supports more than 10 adapters, but we only have built-in 3 commonly used, such as filesystem, memcached, redis. If you need more adapters, you can expand it. For example:

File: config/app.php

File: app/service/Cache.php

See Symfony Cache Component for more information.

Error Handling

Alight catches all errors via Alight\App::start(). When turn on 'debug' in the app configuration, errors will be output in pretty html (by filp/whoops) or JSON.

File: config/app.php

Custom Handler

When turn off 'debug' in production environment, Alight just logs errors to file and outputs HTTP status. You can override these default behaviors by app configuration. For example:

File: config/app.php

File: app/service/Error.php

Job Scheduling

If you need to run PHP scripts in the background periodically.

Step 1: Setting Up CRON

Add the following line to the end of the crontab:

Step 2: Create Jobs

File: config/job.php

Tips

Each handler runs only one process at a time, and the default max runtime of a process is 1 hour. If your handler needs a longer runtime, use timeLimit().

Helpers

Project Root Path

Alight provides Alight\App::root() to standardize the format of file paths in project.

Relative file paths in the configuration are resolved from the project root by Alight\App::root(). For example:

API Response

Alight provides Alight\Response::api() to standardize the format of API Response.

Status Definition: HTTP Status API Error Description
200 0 OK
200 1xxx General business errors, only display message to user
200 2xxx Special business errors, need to define next action for user
4xx 4xx Client errors
5xx 5xx Server errors

For example:

Views

Alight provides Alight\Response::render() to render a view template. Call render with the template file path and optional template data.

File: app/controller/Page.php

File: app/view/hello.php

File: config/route/web.php

The project's homepage output would be:

Others

There are also some useful helpers placed in different namespaces. Please click the file for details:

Namespace File
Alight\Request Request.php
Alight\Response Response.php
Alight\Utility Utility.php

Development

Install development dependencies and run the complete validation suite:

The check command validates Composer metadata, checks PHP syntax, and runs the PHPUnit suite. Individual commands are also available:

Alight supports both cache dependency lines:

PHP Symfony Cache
8.3 7.4 LTS
8.4.1+ 8.x

Continuous integration runs the same tests against both combinations.

Credits

License


All versions of alight with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
nikic/fast-route Version ^1.3
catfan/medoo Version ^2.5
symfony/cache Version ^7.4 || ^8.0
psr/simple-cache Version ^3.0
monolog/monolog Version ^3.10
filp/whoops Version ^2.18
voku/html-min Version ^5.0
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 juneszh/alight contains the following files

Loading the files please wait ...