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 the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to