Sprout web framework.

dev-master 2019-07-11 16:52 UTC

This package is auto-updated.

Last update: 2019-12-11 18:01:21 UTC



Sprout: Minimalist Flexible Web Framework

Sprout Dependencies

A minimal PHP framework to instantly provide routing and templating to any website. A flexible plugin architecture called Roots are available to add as much or as little extra functionality as you'd like.

Table of Contents


  • Apache or Nginx Web server
  • PHP 7.*
  • Composer


After installing and instantiating your website, you'll have access to a $site object in your templates which exposes helper methods from the core and other roots.

Template Helpers

  • $site->trans( $key, $lang ): Translate by key. Translations are registered in ./content/translations.yml
  • $site->asset( $path ): Returns the path to a public asset.
  • $site->global( $key ): Returns the config value in the global namespace.
  • $site->languages(): Get language information. Useful for creating a language switcher with $site->languages('routes')
  • $site->getRoute()->getName(): Get's the current route name.

Extending (Roots)

A basic Root looks like this:

namespace Sprout;

use Sprout\{ Root, Site };

class ExampleRoot extends Root {

	const namespace = 'example';

	public function __construct( Site $site, $namespace = null, $path = __DIR__ )
		if( !$namespace )
			$namespace = self::namespace;

		parent::__construct($site, $namespace, $path);

	public static function namespace()
		return self::namespace;

Building on this, you can define new routes, controllers, views, and add any public methods will be exposed under your namespace on the $site object for use in your page views: $site->example()


Register a route its corresponding controller: $this->site->route($method = 'get', $uri, $controller, $params, $routeName)

The controller has the format {namespace}@method, eg) \SproutSeedling\Controllers\SampleController@show


You can create a redirect like this:

/path-you-want-redirected: /new-path@301


You should extend the Sprout\Controllers\BaseController for some extra functionality. Methods will get the request parameters passed as the first argument:

Eg) public function show( $params ) {}

And the main Site $site will be accessible through the $this->site property.

You can then return a blade view and pass some data like so:

return $this->view('sample', $data);

// TODO:


  • $site->url()->fromRoute( $routeName ) (or shorthand $site->url($routeName)): get's the URL from a route name.
  • $site->url()->fromPath( $path ): get's the URL from a URI path.
  • $site->url()->current(): get's the current URL