Thursday, March 27, 2014

Re: cake 3 - best practice to develop backend app with one or more frontend apps sharing cake lib

Ah ok, well in that case it might be an approach.

Am Donnerstag, 27. März 2014 14:14:16 UTC+1 schrieb bato:
Well,

I think you're right, for classic simple frontend/backend app (one frontend with one backend).
But what about have two completely different frontends with different urls?

Our backend handle multiple sites data and can share content between them.
Every frontend is a completely separate project and it uses backend api to get its data.


2014-03-27 11:50 GMT+01:00 euromark <dereu...@gmail.com>:
Trust me, you will do yourself and everyone using your app a favor if you don't separate the frontend and backend into two apps.
Most of us would just use plugins and/or admin prefixing to cleanly separate the two inside the app.

/
/frontend-controller/

/admin
/admin/backend-controller

Routing like this works just fine in all cases I have ever encountered. And it is what 99% of all people would expect.
One should not overengeneer stuff - its like shooting yourself in the leg here.


Am Mittwoch, 26. März 2014 09:57:46 UTC+1 schrieb bato:
Hi Mark,
thanks for the answer :)
Do you intend using Plugin for backend or frontend? However the common use case we have to handle is:

Is it possible handle with plugins this situation?

On other side we like having separate app for backend and frontends because it give us the possibility to use different plugins for every app and have frontend as app seems more polished.
But if there is a simple way to handle it with plugins I like to know so we can think about it.


Alberto



2014-03-26 2:41 GMT+01:00 mark_story <mark....@gmail.com>:
Have you considered using plugins? If the 'backend' and 'frontend' application run in the same process/server you could probably use plugins quite nicely. If they run on separate servers it gets a bit more complicated.

By using a plugin you can use basic composer features to install the backend code into the frontend one and avoid having to define the full classname everywhere as you can use Plugin.Foo style class names in most places (if there are className options that don't support Plugin.Class let us know)

-Mark

On Tuesday, 25 March 2014 19:19:20 UTC-4, bato wrote:
Hi there,

I played a bit with new ORM and now I'm starting to port BEdita to Cake 3.
BEdita is a Semantic Content Management Framework developed with cake 1.3. The backend is a cake app that can manage multiple frontends data. Every frontend is a cake app too that uses a set of api that are exposed from backend app.

Backend and frontend apps share cakephp lib and backend models, behaviors, helpers are reachable from frontends since they are added to paths with App::build().

Now I try to figure out as reproduce the "same" situations with cake 3 and I would ask some advice.

I'm starting creating the backend app with composer, then I added frontend app by hand beacuse I want to reuse cake core installed in backend app.
So my directory structure is
  • bedita: containing app (Bedita\\ namespace) and vendor with cakephp
  • frontend-app: clean cakephp app skeleton

├── bedita
│   ├── Bedita
│   ├── Module
│   ├── Plugin
│   ├── Test
│   ├── tmp
│   ├── vendor
│   └── webroot
└── frontend-app
    ├── App
    ├── Plugin
    ├── Test
    ├── tmp
    ├── vendor
    └── webroot

To use cake and bedita in frontend app I managed App/config/paths.php and App/config/bootstrap.php

In App/config/paths.php I added the path to bedita folder and modified CAKE_CORE_INCLUDE_PATH to use that.
In App/config/bootstrap.php I change composer autoload path to bedita/vendor/autoload.php and added to it App namespace

// Use composer to load the autoloader.
if (file_exists(BEDITA_CORE_PATH . '/vendor/autoload.php')) {
    $loader = require BEDITA_CORE_PATH . '/vendor/autoload.php';
    $loader->addPsr4('App\\', APP);
}

After that in frontend app PagesController I am able to do:

$images = TableRegistry::get('Images', [
    'className' => 'Bedita\Model\Table\ImagesTable'
]);

The only thing I had to pay attention is how to add behavior in Bedita Table objects. I had to specify the behavior className to avoid errors using those Table objects in frontend app.

$this->addBehavior('BeditaObject', [
    'className' => 'Bedita\Model\Behavior\BeditaObjectBehavior'
]);


So I ask you CakePHP core dev/guru if it is the right way to handle this case or if you have some suggestion or advice.

regards
Alberto


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to a topic in the Google Groups "CakePHP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/MHdseZKF4ts/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cake-php+u...@googlegroups.com.
To post to this group, send email to cake...@googlegroups.com.

Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.



--
------ bato -------

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to a topic in the Google Groups "CakePHP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/MHdseZKF4ts/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cake-php+u...@googlegroups.com.
To post to this group, send email to cake...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.



--
------ bato -------

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: