Create a Laravel Package as Developertool for Concrete5?

Permalink
Hey Community

Hope I am doing this Post right, else just correct me :).

Anyway, my question is, would it be smart to insert / connect Laravel (or an other framework) with concrete5 in form of a package? What do you think of this topic and what would you recomend me, if I want to create a big application, but keeping the CMS functionality of Concrete5?

Regards
Lucien

View Replies: View Best Answer
exchangecore replied on at Permalink Reply
exchangecore
I thought I replied to this thread already but maybe that was just on IRC? Either way, I guess i'm not sure I see building a Laravel package as a useful spending of time. I think that 5.7 is gearing up to be a whole lot more of a framework than <5.6 ever was from a development standpoint. There is definitely a conscious effort being made to make it extendable, and provide a great set of tools to work with from inside of the Concrete5 core, and hopefully shortly after the dust settles on new awesome features great documenting of all the things will shortly follow.

I understand that there are many who use the Laravel framework and it would be nice to have some of the functionality of it (or any other framework for that matter) available. The thing to realize is that those often come with overhead (if not performance than maintainability), and it may also provide much overlap with things that the C5 core has already implemented (since many of the developers working on it also use Laravel extensively and therefore base much of the code off of it).

Just my $0.02.
Remo replied on at Permalink Best Answer Reply
Remo
I agree and since I use both of these systems on a regular basis, I thought about this as well.

Put the complete laravel framework in a package would imho create a mess. You'll have a different routing system in laravel and many possible clashes. Due to that, we've decided to use a bunch of packages using composer.json instead of integrating a complete framework.

It's pretty much the same like Fabian has done herehttps://github.com/worldskills/worldskills-concrete5-package...

Laravel components are easy to use as standalone versions. Not as easy as Aura Components, but still possible in most cases.
tincanIT replied on at Permalink Reply
@exchangecore Probably was a IRC, couldn't find an other question like this ^^. But yea, hope Concrete5 is going to improve there framework, would be great.

@remo I was looking for something like that for a long time, was looking for a good orm-helper, this brought me to this Idea :). Thanks a lot.
Remo replied on at Permalink Reply
Remo
I'm using eloquent in concrete5 as a lightweight alternative to doctrine. This is what I currently have in my package controller, works like a charm:

protected function initOrm() {
          require __DIR__ . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . '3rdparty' . DIRECTORY_SEPARATOR . 'autoload.php';
          $capsule = new Capsule;
          $capsule->addConnection(array(
               'driver' => 'mysql',
               'host' => DB_SERVER,
               'database' => DB_DATABASE,
               'username' => DB_USERNAME,
               'password' => DB_PASSWORD,
               'charset' => 'utf8',
               'collation' => 'utf8_unicode_ci',
               'prefix' => ''
          ));
          $capsule->bootEloquent();
     }
Justin1978 replied on at Permalink Reply
Justin1978
I'm surprised that works, I gave it a try and noticed Concrete 5.7 uses a different version of some Iluminate packages which clash with Eloquent (Container class or interface). The Concrete autoloader intercepts my Composer autoload dump. I abandoned Eloquent now. I tried Doctrine but I find it frustratingly hard to get started and the usage/syntax is so much more complicated than Eloquent. Eloquent is so intuitive that it actually works how you think it will. You probably gave both ORM's great consideration but I personally would prefer Eloquent over Doctrine any day.
Remo replied on at Permalink Reply
Remo
That code I'm posted is just an old example. I'm using that in 5.6 projects, not 5.7.
I'm aware of those clashes, I got them almost always when I played around with 5.7. There are suggestions on how to remove that duplicate composer.json thing but unfortunately nothing has changed yet..
afixia replied on at Permalink Reply
afixia
I got Eloquent to boot in Concrete 5.7.5.*

You have to use 4.1.* since Concrete 5 autoloads the illuminate/container : 4.1.* but I'll take it over doctrine any day.

/packages/eloquent/libraries/composer.json

{
  "require": {
    "illuminate/database": "4.1.*",
    "illuminate/events": "4.1.*"
  }
}


-- update composer
/~packages/eloquent/libraries$ composer update

/packages/eloquent/controller.php

<?php
namespace Concrete\Package\Eloquent;
defined('C5_EXECUTE') or die(_("Access Denied."));
require __DIR__ . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
use Concrete\Core\Package\Package;
use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Events\Dispatcher;
use Illuminate\Container\Container;
class Controller extends Package
{
    protected $pkgHandle = 'eloquent';
    protected $appVersionRequired = '5.7.1';
    protected $pkgVersion = '1.2';
    public function getPackageDescription() {
        return t('Enables Laravel Eloquent ORM in Concrete5.7');


That boots it globally so just add your models like normal...

/packages/eloquent/src/Models/C5User.php

<?php
namespace Concrete\Package\Eloquent\Src\Models;
defined('C5_EXECUTE') or die("Access Denied.");
use Illuminate\Database\Eloquent\Model as EloquentModel;
class C5User Extends EloquentModel{
    protected $table = 'Users';
    protected $fillable = [];
    public $timestamps = false;
}
puneeth replied on at Permalink Reply
Hi Alex i tried used your technique for extend eloquent as package.. i am getting following error.. can anyone please guide me.. how to fix it..

Argument 1 passed to Illuminate\Database\Capsule\Manager::setupContainer() must be an instance of Illuminate\Contracts\Container\Container, instance of Illuminate\Container\Container given, called in D:\xampp\htdocs\html\packages\healthenablr\vendor\illuminate\database\Capsule\Manager.php on line 33 and defined
puneeth replied on at Permalink Reply
Hi Remo i tried used your technique for extend eloquent as package.. i am getting following error.. can anyone please guide me.. how to fix it..

Argument 1 passed to Illuminate\Database\Capsule\Manager::setupContainer() must be an instance of Illuminate\Contracts\Container\Container, instance of Illuminate\Container\Container given, called in D:\xampp\htdocs\html\packages\healthenablr\vendor\illuminate\database\Capsule\Manager.php on line 33 and defined
Justin1978 replied on at Permalink Reply
Justin1978
This has to do with version incompatibility. I had the same problem.
Concrete uses an older version of the Illuminate package.
On Jul 5, 2016 11:42 AM, "concrete5 Community" <[email protected]>
wrote: