Download the PHP package nearbycreative/light-framework without Composer
On this page you can find all versions of the php package nearbycreative/light-framework. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nearbycreative/light-framework
More information about nearbycreative/light-framework
Files in nearbycreative/light-framework
Package light-framework
Short Description Light Framework makes it ridiculously easy to throw up a powerful JSON API
License MIT
Homepage https://nearbycreative.com
Informations about the package light-framework
Light is a micro-framework for quickly spinning up powerful APIs. It can be used both as a standalone framework or embedded into an existing application.
Frameworks like Laravel and Symfony are powerful, but when you need to build out an API, a web framework with the whole kitchen sink can over complicate with option overload.
Light aims to use familiar open source technologies like Eloquent and Phinx, with simple paradigms like MVC to make building out APIs lightning fast.
Requirements
- php7.2+
- A web server with
mod_rewrite
enabled
Quickstart a Fresh Project
If you're starting your project from scratch, the following commands will get you up and running quickly!
mkdir myproject && cd myproject
composer require nearbycreative/light-framework
./vendor/bin/light init
php light serve
That's it! You can visit http://localhost:8080 to see Light in action!
Directory structure
light init
creates the following directory structure:
app/
controller/
Welcome.php
model/
database/
migrations/
seeds/
public/
.htaccess
index.php
resources/
js/
sass/
views/
.env
light
Note, this is the default scaffolding to get a new application up and running quickly. If you're including Light
into an existing project, you probably don't want to run light init
, but rather embed it. Learn how to embed Light in an existing application.
Using route closures:
If you look at the generated public/index.php, you'll see it provided a few simple routes to start you off. If you wanted to, you could create your entire application in a single file using just route closures, ie:
An example index.php:
Spin up a test server with php light serve
command.
Visit: http://localhost:8080/test
You'll see the following output:
Visit: http://localhost:8080/test/this-is-cool
You'll see the following output:
Using controllers
Putting all your API endpoints in route closures works fine for small APIs. Though, this can get pretty narly, pretty quickly. Another way to organize your API code is using Light Controllers.
You can create a controller in your application that extends Light\Controller manually, or use the php light make:controller
command.
Ie: php light make:controller Test
will generate the following controller in _app/Controller/Test.php:
Inside index.php add the following route that points to the controller action you just created:
Use php light serve
to test out your new API endpoint:
Visit: http://localhost:8080/foo
Command Line Utility
Try running php light help
to learn about more things you can do with the command line script.
Learning more:
The following docs are coming soon!
- Routing
- Requests
- Controllers
- Models
- Migrations
- Pagination
- Helpers
- Authentication
- Light Command Line Utility
- Embedding Light into existing projects
- Using Light as a full MVC Web Framework too
All versions of light-framework with dependencies
ext-xmlrpc Version *
php Version >=7.2
nikic/fast-route Version ^1.3
illuminate/http Version *
illuminate/database Version *
robmorgan/phinx Version ^0.11.4
twig/twig Version ^3.0
psy/psysh Version @stable