Jump to content

Prestashop + Laravel = Illuminato !


Recommended Posts

Hi folks,

I've been playing a lot with Laravel and Prestashop this days and came up with a Prestashop's module that let you build other Prestashop's modules using Laravel API and philosophy.
You might want to check it out :

It's still a work in progress and it's not production ready but I wanted to know if people were interested in such project.

If so, please let me know by staring the projet on github, forking it, report bugs, ask for features etc.

Hope you'll enjoy it,

  • Like 3
Link to comment
Share on other sites

  • 5 months later...

This topic is so much interesting... It will be a revolution to build such kind of bridge between these lovely tools.

I hope you will keep working on it... and a bit of time later I'll have more knowledge in Prestashop.. I'll be more than happy to contribute into your project.

Wish you the best and good luck

Link to comment
Share on other sites



Thank you for your repply.


Unfortunetly this tools will never be able officially to Prestashop cause it requires php 5.5 at least and some modification to prestashop core.


I stop working on it but got pretty far, I was able to do migrations, use ORM, localisation and a lot of things the Laravel's way :).


The module creation was also quite simple and strait forward, I took inspiration from October CMS which is the greatest CMS I know.


If you need more information or need help playing with illuminato, don't hesitate. If people show some interest I'll maybe consider working on it again.

Link to comment
Share on other sites

This a pretty amazing project. I've been using it for several tests and I believe it has quite a lot of potential. However, I have a doubt i hope the author can help me with.


You see, in one of my tests I wanted to use an additional function within the module ("public function test()"):



class LaravelModule extends Illuminato\Module {

	public function moduleDetails()
		return [
			'namespace' => 'LravelModule',

			'tab' => config('LravelModule::module.tab'),
			'version' => config('LravelModule::module.version'),
			'author' => config('LravelModule::module.author'),

			'displayName' => config('LravelModule::module.name'),
			'description' => config('LravelModule::module.description'),

	public function install()
		if (!parent::install())
			return false;
		return true;

	public function getContent()
		return view('LravelModule::backend' ]);

        public function test()
                //return 'Hi there!'; //WORKS!
                return view('LravelModule::exampleView'); //DOESN'T WORK! (It only works when "test()" is called from "getContent")


However, just as I comment in the example above, I seem to be unable to call Laravel helpers (or use any of its classes/methods, for that matter) from the additional function, they seem to work only from the "getContent" method, or any other method called from it. Trying to extend laravel's functionality to this kind of additional methods has led me to a dead end. Any pointers?




My original idea was to emulate Laravel's controller funcionality using another PHP file that would act kinda like the usual "routes" file in Laravel:


$functionData = preg_split('@/@', $_SERVER['PATH_INFO'], NULL, PREG_SPLIT_NO_EMPTY);
echo $functionData[0]($functionData);

function helloWorld($arguments)
    return 'Hello World'; //WORKS

function test($arguments)
    return view('LaravelModule::exampleView'); //DOESN'T WORK

This way I can trigger those two functions by accessing their respective URLs:


www.myshop.com/modules/laravelmodule/routes.php/helloWorld -> which works and returns the correct "Hello World" string.

www.myshop.com/modules/laravelmodule/routes.php/test -> which doesn't work, apparently beacuse it uses a laravel function (the same thing that happens in my first example).


Thanks for your time:




EDIT: Alright I figured it out. It's a matter of bootstrapping the framework again in the file that will use methods from Laravel. Here is an example based on my "services.php" example from above:


include_once '../../config/config.inc.php' ;

require _PS_MODULE_DIR_ . '/illuminato/src/bootstrap/autoload.php';
require_once _PS_MODULE_DIR_ . '/illuminato/src/Module.php';

$app = require_once _PS_MODULE_DIR_ . '/illuminato/src/bootstrap/app.php';
$kernel = $app->make('Illuminate\Contracts\Http\Kernel');

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()

//Use the languge specified in PrestaShop's configuration
$context = \Context::getContext();

$functionData = preg_split('@/@', $_SERVER['PATH_INFO'], NULL, PREG_SPLIT_NO_EMPTY);
$response->content = $functionData[0]($functionData);

$kernel->terminate($request, $response);

function helloWorld($arguments)
    return view('LaravelModule::exampleView');//IT FINALLY WORKS!

Please, note that, for the above example to work, I had to make a couple of modifications to the framework:


-Marked the "content" attribute of the response as public (I know it's a hack; it's supposed to be modified by the routing engine, but that's not available in Illuminato... yet? You may want to do the same with the "statusCode"/"statusText" member variables).

-Added the "terminate" method to the app class (IDK why it wasn't in Illuminato, it doesn't do much but it can't hurt to have it, either ;)).


Hope it helps:



Edited by SkyBladeCloud (see edit history)
Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...