Installing Yii2 advanced in an Opencart directory

Hi folks,

I want to install Yii2 in the root of an Opencart installation as I would like to make certain core Yii framework files available to Opencart. I would also like to have a functioning Yii2 advanced application within the Opencart root directory.

The Opencart root currently looks like this: -

I think if I installed Yii2 advanced, the vendor directory would be the only overlapping file or directory.

Can anyone recommend the best approach to this? Thanks.

Take a look at the BASIC Yii 2 application template, and modify the composer.json in your OpenCart installation, adding the Yii 2 composer packages to it.

When you’ve installed Yii 2 into your OpenCart installation, and it works, then you are ready to create a Yii 2 application in your OpenCart dir.

I think you should do this manually.

And I also think that you need to forget about the advanced template.

Do you really need two separate Yii 2 applications in your OpenCart application?

Thanks for the help.

I was thinking about having a bit of fun by trying to replicate some of the Opencart functionality in Yii2 as both a frontend and admin side. So I was hoping to have both the Opencart and Yii advanced apps working so I can work with both in PHPStorm at the same time.

As I am on my phone, I am sort of blind, but I am sure I’ve seen OpenCart and Yii together somewhere…

Okay, so since OpenCart uses Composer, it should be possible to let it and Yii cooperate.

Still, what’s up with the ad advanced template?

I am telling you :there’s no reason to use it, unless you need two separate Yii applications!

The basic one is what I always use…

The advanced template was so I would have a frontend and a backend, to replicate the frontend (web) and admin of Opencart.

The only mentions of Opencart and Yii are implementations with Yii1.

So I have now installed the yiibasic app in the root of the Opencart project. I installed it from the command line. So now the only instance of the Yii framework I have is in the yiibasic>vendor folder. I would ideally have this available in the main vendor folder in the Opencart project root but I can’t get it to install via composer.json.

How do I make the Yii framework classes available to PHPStorm and the Opencart app? Do I need to call the autoloader in the yiibasic root?

You can’t just require Yii 2 in the OpenCart Composer.json ?

About the admin backend: just use a module. It’s much simpler than using the advanced application, which requires you to setup two hosts.

Thanks for your help!

I’ve managed to get the Yii2 framework to install after trying (and failing) maybe a dozen times today. Odd. Anyway, it’s done now. A restart of PHPStorm and it’s showing in the intellisense now. Hurrah!

Re: just using a module for admin. I think you may be right. Right now I am just trying to replicate a the admin console of Opencart. If I can do that, I might go for some additional functionality such as a CMS too. I dont think that is too ambitious, although it will be time-consuming. If I can get that done, I am thinking about setting up the Yii admin module as a REST application and API with an frontend built in React.

Here come some late nights…

I am currently developing a site using the advanced app. The admin (backend) is a very different app from the frontend, so I wanted a total separation of concerns as it uses a different layout etc. You think there are really no advantages to this and I should just use a module instead?

Modules can use their own layout, so you should be fine.

Modules are also easy to re-use, so that’s a plus.

And they don’t require a separate virtual host.

It’s your choice, but modules should provide everything that you want.