PHPackages                             sparkle/sparkle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. sparkle/sparkle

ActiveProject[Framework](/categories/framework)

sparkle/sparkle
===============

Sparkle is a free to use open source php MVC framework for building web applications. It's very simple to work with and has a very low learning curve.

v2.0.3(2y ago)2421[1 issues](https://github.com/loftytech/sparkle/issues)MITPHP

Since Jun 30Pushed 1y ago1 watchersCompare

[ Source](https://github.com/loftytech/sparkle)[ Packagist](https://packagist.org/packages/sparkle/sparkle)[ RSS](/packages/sparkle-sparkle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)DependenciesVersions (8)Used By (0)

sparkle
=======

[](#sparkle)

Introduction
------------

[](#introduction)

Sparkle is a free to use open source php MVC framework for building web applications. It's very simple to work with and has a very low learning curve.

Getting started with sparkle is very easy. All you need to do is have `php version >= 8` and `composer` installed on you computer.

> composer is a package manager for php

Then in the root directory of the project, run this command:

```
composer create-project sparkle/sparkle .
```

Alternatively you can create a new sparkle project in a new directory:

```
composer create-project sparkle/sparkle my-project
```

To start the server, in the root directory of the project, run this command:

```
php star light
```

This would start the php dev server on port 8000 and load the environment variables in the `.env` file if you have one.

In production, you can load the environment variables using this command:

```
php star configure
```

Sparkle is built to be light weight and reliable so it doesn't come with any third party packages but you can extend sparkle by installing third party packages via composer.

Views
-----

[](#views)

Sparkle was designed for REST api development but also supports basic view templating.

To create a new web page, go to the `views` directory and create a new file. Then in the `routes/web.php`, add a new route like so:

```
Route::get('/some-route', function() {
	View::make("ViewName");
});
```

Inject data into your views by adding an associative array of key value pairs as the second argument like so:

```
Route::get('/some-route', function() {
    View::make("ViewName", ['site_title'=>env('APP_NAME')]);
});
```

use the variable in your view file using double curly brackets like so:

```
{{ site_title }}
```

> You could aslo use a controller to handle view rendering

create a controller by going to the `app/Controllers` directory and creating a new file with a class extending the base controller.

Controllers
-----------

[](#controllers)

```

```

Models
------

[](#models)

Now lets create a model for our user controller. You can do this by going to the `app/Models` directory and create a file, let's say `UserModel.php`

now add this snippet:

```
