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 light-weight PHP framework. Easily and quickly build high performance RESTful web applications. Out-of-the-box built-in routing, database, caching, error handling, logging and job scheduling libraries. Focus on creating solutions for the core process of web applications. Keep simple and extensible.

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 7.4+

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.17.10, PHP 7.4.3, Ubuntu 20.04.3):

Configuration

All of the configuration options for the Alight framework will be imported from the file 'config/app.php', which you need to create yourself. 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 first that stores routing rules. Because the routing cache is updated or not, it is 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().

Before handler

If you want to run some common code before route's handler.

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/admin.php

File: config/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 'options' will be passed to the cache adapter, more details please refer to Available Cache Adapters. 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 to the end line:

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.

The file paths in the configuration are all based on the 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 display a view template call the render method with the path of the template file and optional template data:

File: app/controller/Pages.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

Credits

License


All versions of alight with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
nikic/fast-route Version ^1.3
catfan/medoo Version ^2.1
symfony/cache Version >=5.4
psr/simple-cache Version >=1.0
monolog/monolog Version >=2.9
filp/whoops Version ^2.15
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 ....