We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Using modules with Micro applications

How to use modules with micro applications, as it does not have registerModules.

I am sorry this is not helpful.



98.9k

Modules are intented to be used with a dispatcher, so you need the full mvc, a micro application is not capable of running a module-based architecture

@Phalcon

I need to build an API for already developed modular application, is there any workaround to achieve that?



98.9k

Module-based applications require a dispatcher which a micro application lacks of, Maybe you can use a different namespace for those controller in the backend and those in the frontend loading from different directories.

<?php

use Phalcon\Loader;

$loader = new Loader();

$loader->registerNamespaces(array(
    'Biko\Frontend\Controllers'  => '../apps/frontend/controllers/',
    'Biko\Backend\Controllers'  => '../apps/backend/controllers/',
));

$loader->register();

@Phalcon I think this is answer is not related to the question, re-phrasing my question again.

I already had developed a mutli module application, and I need to build a REST API on the top of this application and by having the benefits that the Micro application provides, any workaround for this?



26.3k

You have a multi module application. What is the reason you do not want to build this REST API as a new module?

@Conradaek It seems there is a miss-understanding, I don't want to build a new module for the API, I just need to provide an API for the already developed functionality regardless of the method used for implementation.



26.3k
edited Jul '14

So, as I understand you, you have some app e.g. BalconyManagement app. Users can log in and add flowers which their plants on their balconies. There are flower forms, balcony forms etc.

And now you want to add API functionality so that user can do the same but communicating via URLs, e.g. for an Android app, so now adding a new flower will be possible via URL:

https://BalconyMgt.org/api/SomeUser/SomeMd5Pass/AddFlowerByName/MyBeautyRoseCharlie/ which will e.g. generate an output in JSON e.g. SUCCESS, flower added.

Am I right?

If I am right I think one of the solution will be to leave idea of REST API as a micro aplication and to build this REST API functionality as a new module. What do you think?

Hi @Conradaek

You are right, and I thought about building another module, but I wanted to use micro applications because of their features, so I was asking if there any workaround to do so?

Thanks alot for your help :).