CakePHP Development of frontend/backend application - php

I have to develop frontend/backend application using cakephp.
can you give me advice how should i develop them, using same cakephp library?
or I have to develop them using separate cakephp libraries?

I am confused - cakePHP would be used to implement both.
PHP would be used to implement the server-side backend. The same "project" would also contain HTML, JS, CSS, etc that will be used to render the front-end within the browser. Any PHP "views" will also execute code on the back-end, although any HTML output will be rendered on the frontend.
Does that help at all? Or am I missing something?

If by frontend/backend, you mean an application with a user interface (frontend) and an administration interface (backend), then you want to refer to the Prefix Routing section of the manual. This will allow you to have separate flow and interfaces (controller/view) for each type of user while sharing the same data (models).
If by frontend/backend, you mean an application (frontend) that communicates with another server application (backend) using web services, then you want to look at the Additional Class Paths section of the manual. This will allow you to share common classes with two (or more) separate applications.
Note: the above links are for CakePHP 3.x, though these features have existed in one form or another since v1.2.

Not quite sure if I understood you correct, but if I did:
You can set up multiple projects using the same cake-core files. The core files don't even need to be placed in the webroot folder..
http://book.cakephp.org/view/35/Advanced-Installation

For your own sanity, you should regard the backend management as part of the same project as the frontend.
The systems I have built generally use view-type methods for the public view and crud-type methods for the admin view. How you lock down the admin is your choice. Personally I don't like the default admin prefix way. I use login and ACL - Mark Story's tutorial on http://book.cakephp.org/ is superb. With that you can password protect methods.
CakePHP is very flexible and extensible and you can make the administration as simple or as flexible as you like.

Related

Yii2 Rest API Location

I needed to know which folder is more suitable to host my Rest API in Yii2 template advanced, backend or frontend.
I also saw some examples where developers created a new directory, called it "api" and programmed the API from there, but I don't find much information by developing from this method.
If you know the most correct way to do it, I would apreciate if you could explain me.
That totally depends on your requirements if it is going to be a complete full app or just a single controller with a few actions or a single ActiveController.
But a good way is to keep things separate just like you are using the advance-app and you have the backend and frontend folders so that you can differentiate the code base, and keep the code in their concerned folders, those folders are actually 2 separate applications running separately with their own separate configurations i.e backend/config/* and frontend/config/*, and can share some common configurations like database and others from the common/config/*. Same like that you can create a separate application/folder where you can have all the code base and configurations related to api you are going to build.
You can find a very good reference for adding more apps into your existing application by Yii here on GITHUB which will clear your concept about how to add more apps.
Then you can go to this article by Budi Irawan's Tech Blog which uses the advance-app to add a new application for the API. You will find the directory structure with example models and controllers along with testing them with POSTMAN.
Backend and frontend are also just a folder in the Yii2 advance app with just namespace different, they are different for our understanding, it is not necessary that you use backend for backend purpose only.
So for the API, you can use any of these folders, but it is always recommended to put thing separately like we put backend thing in backend folder and frontend things in frontend folder.
It's totally up to you and your coding style.
i prefer putting Rest API into a separate module, for instance into "common\modules\api". that way i can "mount" the api in backend or frontend via configuration. Also, nice urls are automatically provided, like /api/<controller>/<action> (where api is the name of your module).
One more thing to consider is how to update your api. in case of modules everything is well organized. you could start with "v1" and put your controllers in here, and move up to "v2" with a different set of controllers. so your first api endpoint would read /v1/users, later on you can additionally provide /v2/users.
more about modules here
read "URL Rules" here

When should we use multi-module structure (instead simple structure) in php Phalcon

When should we use multi-module structure (instead simple structure) in php Phalcon?
I have found some multi-module skeleton, such as:
https://github.com/ovr/phalcon-module-skeleton,
https://github.com/phalcon/mvc/tree/master/multiple.
But I don't know should i use this multi-module structure in a project instead use multi projects.
Something i can think about it is: more complex configuration, complex folder structure, my web url be longer (/[module]/[controller]/[action]) and , importantly, performance will be low (for more loading things than).
However, I think that there are something interesting with it (so many ITer had used it). Is there Someone can give me advantages, disadvantages and criterias for selection.
P/s: the same problem with Zend2 Module!
If you are building a single purpose application as an API that does not use Views, you should rather use single module structure. If it will be a realy simple API of for example storing/logging, micro app will do aswell.
Multi module application structure is useful if you are willing to build more complex solutions. For example an public application with public content, but with admin panel. This one would be handy to write in multi-module to separate administrative controllers/views from those public ones.
My habit is to use multi-module structure, because mostly I have to build applications that are CRM's with their API and an public accessible content part (eg. docs). For such purpose it's just handy to create such modules as:
frontend - for controllers accessible by everyone
backend - for controllers accessible after authentication and authorisation like administrative things
API - for API purposes ;)
common - a part I rather am willing not to implement, but in one project I'm forced to put here some abstract controllers that will be extended in other modules.
This way you can keep separate services configuration for each module, what saves you from cutting off things that you are using at purpose of module A, but not on module B. Like authentication part - important for backend, but useless for frontend part. Or Database configuration - slaves for frontend, master for backend, etc. So this may be also a performance-wise solution for big projects.
Update
Sometimes "multi-project" is an option including "multi-module" project ;) It strongly depends on what you are trying to achieve. Eg. if you take API apart, it may be easier to scale it over multiple instances, but at first it costs you an efford to configure separate project.
If system is supposed to be single-server instance or every istance should be absolutely independed on other instances, single multi-module project will be enough - lets say a standar CMS, blog platform, even simple browser game or homepage of mobile app including API for it. But if you are building a whole universum of apps like an internal API to privide content, CRM to manage it and a couple of web pages to serve it, keeping these as separate projects will be easier to manage later.
Well for example I in my application im splitting every functionnality - for example i have model Link - it's splitted to seperate module to have nice application structure where each funtionality is seperated module. It's like less classes to load in loader. Beacause you only need models and routes from each module to load for whole app, and you load other things like librarys/controllers/helpers/services in module.

Using wordpress and django togther

I am developing a web application using Django and python. We have also a public website where a customer can find information regarding our products. I was thinking to implement this website using WordPress or other well known php CMS, since the content may be modified by people who don't know how to code.
A user must login to access our web application. The login should be located in the public website (built using php and a CMS) along with the registration form. The user model is already implemented in the web application and therefore is not available in the CMS/php. I was thinking to include a login page written in python by means of an iframe. is it a good idea?
Is there a neat solution for this problem? Is a good idea to mix up php/cms and python/Django?
There is an opensource CMS for Django called Mezzanine. Its very elegant.
In some ways, Mezzanine resembles tools such as Wordpress that provide an intuitive interface for managing pages, blog posts, form data, store products, and other types of content. But Mezzanine is also different. Unlike many other platforms that make extensive use of modules or reusable applications, Mezzanine provides most of its functionality by default. This approach yields a more integrated and efficient platform
Follow this link to download and have a look at its features
Regarding you question Is a good idea to mix up php/cms and python/Django?, No, because Django is Python based and wordrepss is PHP based. Although you can sync data by writing different scripts that require some knowledge of both ends.
There is another option https://www.django-cms.org/
This is specially usefull if you have already a django project, because you can add to the project the CMS components, Mezzanine is a very good option too, but you have to start the project from scratch.

PHP framework that can be included in other projects

I have a little specific concern, I hope you can help me, I have to develop an application in PHP that doesn't need to be linked to the exclusive use of its installation and could be used or "included" in other projects of PHP, I mean, to develop a web application (such as generation of a graph according to certain parameters passed) that can be used on different pages created for example in phpBB, Drupal, Dreamweaver or PHP Frameworks like CodeIgniter and Zend.
The best example of what I mean is "Google Charts Tools", you just print in the browser the access to the tool with the parameters and the tool does the rest, and this does not depend on the type of framework with which the home page was created.
In short, I'm looking for a framework or lightweight framework with which I can develop an application that simply could be called in an include() or require() on the destination page and can be used, a framework that can somehow "export" the project or application and could be used on one page without having to reinstall the framework on the target server, even the libraries could be included in the target page so you can run the application.
Was working with Codeigniter and tried to attach to a Joomla page but i couldn't because Codeigniter is linked to the URL of the page and I dont want to use Iframes.
Is there something like that?
First of all; I believe you would need some custimization, as frameworks just aren't build that way. But it isn't impossible. In Kohana for example (also codeigniter, but kohana is more flexible), you can build internal requests with Request::factory($uri). If you can find out a way to bypass direct access to index.php, or build a wrapper after which you can do stuff in the Kohana 'environment' you could do it. I don't have a ready-to-use solution, but if you try something and post the code we might be able to help you out some more!
Sounds to me like you want to write a library or class that can do certain things and which can be reused in other code. You can then build an example application around it, using a framework, which uses this library.
If you start with a whole framework, this often makes it really hard to reuse any part of the code, since the framework has certain assumptions or requirements which may not always be true for other projects. As a general rule: a framework is already a complete standalone application. What you want is something smaller than that.
Of course, you can have a look at a framework like Zend, which is basically just a loose collection of individual classes. Together they form a framework, but each part of it is individually usable. Something like CI is on the other end of the spectrum, much more heavily coupled and interdependent.

Need to Assess whether Joomla is good fit for Web Application Requirement

I have a web application that needs to be built using PHP/MySQL. The application will require documents to be generated from data in the MySQL database. Such documents will be printed and/or emailed and user will be prompted to run a daily print/email job based on business logic.
This application functionality needs to be made available to individual users such that they can upload data, have the system prompt them as to whether letters/emails are to be generated. The site also needs to be able to support a bulletin board, online live training events and will have admin area as well.
Question: Should a hybrid solution be developed such that the data management (upload functionality, and letter production) be a separate part of the site that authenticated Joomla users can access? That is, the document management functionality would exist separately from Joomla, but be called from within it via a link in the Joomla sitemap. Alternatively, should custom modules be developed from within Joomla to accomodate the document management functionality?
Thanks so much for your input!!
Joomla could do the job for you but based on the amount of things you need that differ from a normal Joomla site I would use a framework to build from instead of a CMS. I say this because it sounds like you need a lot more than just a CMS and it can be more work if you try making Joomla do things it wasn't designed to do. In my opinion Joomla is for "web sites" and not as much for "web apps". Of course those terms have overlap but it sounds like you would be better off with a Framework to go off of instead of working around Joomla to get what you want. However if the site is already done in Joomla it may be less work just to make a Joomla add-on.
Since you have to use PHP I would definitely recommend CakePHP for your framework. As for an integrated forum try looking at the links in this post. If that doesn't work for you, try out Vanilla forums (vanillaforums.org) which are very clean and may be easier to integrate into CakePHP than some of the other PHP forums.
If you decide to use CakePHP, check out Cake Forge to see if you can find anything there to make your life even easier.
If you were to use Joomla, the upload functionality and letter production would be written as a custom component. You can write the component to make sure that the current user is authenticated before generating the documents. I would not develop this as a separate application alongside Joomla; it would be easier to write it as a component.
Many forums and forum bridges are available for Joomla, so that would be something you wouldn't have to write.
I'm not sure what kind of live event support you're looking for.

Categories