Integrate Wordpress CMS in CakePHP - php

I'm trying to integrate Wordpress in CakePHP 2.6.1 to use it as a CMS for my end users.
I'm including the required file to access wordpress functions: wp-blog-header.php.
As CakePHP only allows to include files located inside CakePHP I placed the wordpress intallation inside app/Vendor/wordpress and now I'm trying to import the necesary file in my AppController in this way:
App::import('Vendor', 'wordpress'.DS.'wp-blog-header');
But it seems there's some functions conflict as I'm getting this error from CakePHP:
Error: Cannot redeclare __() (previously declared in /home/todopeta/alvarotrigo/pruebas/cakephp/lib/Cake/basics.php:581)
File: /home/todopeta/alvarotrigo/pruebas/cakephp/app/Vendor/wordpress/wp-includes/l10n.php
Line: 163
Has anybody integrated wordpress in CakePHP before?
What's the way to go for it?
I've seen it seems to be possible with other PHP MVC frameworksk such as Laravel.
Is CakePHP more restrictive in this respect?

Access the WP data by creating a WP plugin for CakePHP and add a model for each of the WP tables and read the data via CakePHP.
Your linked article does the same but it uses the WP_Query class and further down Corcel which seems to be a mix between the Eloquent ORM and WP. I would not go that path and use the CakePHP ORM.
I can guarantee you that everything else is going to become a pain in the rear thanks to the fugly WP code and architecture.
If you try to use the WP code inside CakePHP like you've tried this will become super painful, time consuming and probably never work right without some really really fugly code.
If you need only parts from WP consider creating a WP plugin and embedd the WP content via an iframe in your page. AFAIK WP got a json API as well these days, you could try to read the data via that API as well.

You're going to have a nightmare and end up with a massive mess of code with this approach.
Instead, why not try and use a CakePHP CMS system, for example:
https://croogo.org/

Related

How to call laravel function in Wordpress themes

I am currently developing a laravel app which I only managed the blog section with Wordpress. Everything works fine. Is it possible to call laravel function in my Wordpress function.php? If yes, how can I achieve that?
It will depend on what function you want to call. Some things can be used independent of the framework simply by including the packages, for example Laravel Collections. However if you need more in depth integration you should take a look at the following files.
public/index.php
bootstrap/app.php
bootstrap/autoload.php
It is in these files that the frameworks gets loaded. Meaning that it does all the prerequisites before your application code can run. If you wanted to use Laravel within WordPress you would need to mimic the logic from these files in WordPress. I have never done this before though, so I don't know if you will encounter any namespacing issues or anything else. You might also be concerned about the performance implications of loading WordPress and Laravel on every request. Good luck!

Wordpress Functions in CodeIgniter? (Controllers, Models and Views)

Is there any way to access WordPress functions in CodeIgnighter? Basically I am running a website entirely using WordPress but I need to build a custom add-on system that needs to be separate from WordPress (so not a plugin). Thanks to this link
I can get WP functions working in views but not in controllers or models.
My folder structure is WordPress installed in site root then the CodeIgnighter in WordPress: root/wordpress/codeignighter
I need this as I want to use WordPress user functions so people can use the CI system with their WP accounts.
Turns out this was an error on my behalf I forgot to declare some global variables as the linked solution clearly states. My bad

Building a Joomla component from an existing PHP script

I am working on a freelancer site that will use Joomla as the base. I would like to create a custom component for the freelancer functionality and was wondering if there is a way to convert an existing freelancer PHP program (specifically Ilance) into a Joomla component. I have a license for Ilance and thought about using the wrapper in Joomla for it. But this option will not work for me. Instead, I would like to add all the functionality of Ilance into Joomla without creating it from scratch.
OFC you can do that. Joomla components should be MVC but they don't need to. They can actually be any (crappy) code you want. That's why everyone calls himself a pro joomla developer ;)
You only need to work your way into creating the basic joomla bootstrapper file and some installation xml and off you go.

Using Laravel bundle with CodeIgniter

I want to use Laravel Bootstrapper bundle http://bundles.laravel.com/bundle/bootstrapper with my CodeIgniter application.
How can i utilize autoloader functionality to use Bootstrapper bundle code in CodeIgniter in native PHP 5 fashion.
Button::make('Abc')->with_icon('ok');
Do you suggest to convert Bootstrapper bundle in CodeIgniter library or we can use it as it is.
I am using bootstrap for creating views, thus already including bootstrap specific css, js & images.
Please help, so that the bundle can be used with CodeIgniter
Why? It's not designed to work with CI, you'll probably have to mess about alot to get it working. See one of the many versions available for CI here https://github.com/vesparny/codeigniter-html5boilerplate-twitter-bootstrap.
Further more, I dont see any great advantage of having a bootstrap CI integration, if you do then go for it but I just use my own customised bootstrap and load it in as normal in template/view files. Works just fine and keeps all those UI/view bits and pieces separate for designers/Front-end coders who panic at the sight of php.
All this work trying to keep design, function and layout separate and people go to great effort to ruin it with something like this.

What is the proper way to develop a custom theme/template for Magento 1.4

I have recently started working on an eCommerce site for a company and they have selected Magento 1.4.0 to run their store. I have spent most of my PHP "career" working with various MVC frameworks (even Zend with Magento is supposed to be based on) but the complexity of Magento seems to be on another level with no seemingly good resources to look to for help.
Looking around the site I have seen suggestions for certain books to use as reference, but they all refer to Magento 1.2 or 1.3.
My goal is to develop for Magento in a way that I do not alter any of the base code so that the client can easily upgrade the version of Magento and just "drop in" my code and have it work. The current issue is how to properly use the layout/template breakdown correctly and how to add custom model/controller functionality to the application without hacking away at Magento's core code base.
how to properly use the layout/template breakdown correctly
What you need to know is the folder structure of the Magento & the use of its own MVC structure. This is a very very important part to get you started from the basic roots. Whatever version you use, the folder structure & the MVC structure followed by Magento will almost never change. Try to follow the Magento's own Knowledge Base & Wiki tutorials. If you want you can also follow some other sites as well.
how to add custom model/controller functionality to the application
without hacking away at Magento's core code base
You will need to use the custom module functionality to override the core code base of model / controller. It's a simple process of writing the main logic in a XML file, of what core class you want to override of Magento, in your module's "etc" folder. Try to understand the process first, from the Knowledge Base & Wiki tutorials, to get a firm grip on overriding core classes.
I hope this helps.

Categories