A
A
ADA M2017-07-08 09:46:23
Yii
ADA M, 2017-07-08 09:46:23

How to create a new application (object) in Yii2 basic template?

I read the documentation on Yii2 and did not fully understand how to properly create a new application. Also, there are no detailed instructions on the Internet.
I'm trying to place a new application in a new directory, I threw folders with controllers, models and views there.
If I understand correctly, the main changes will affect the configuration ( id, basePath, aliases, controllerNamespace) for web and console (to use migrations, etc.), and namespacefor all internal files of this application.
In theory, everything should work, but I get this kind of error:

The file or directory to be published does not exist: E:\XAMPP\htdocs\local.dev\new_app\vendor\bower/jquery/dist

In general, you are creating a new application? Is it normal practice to create subdirectories for every new application?
The task is something like this: there are different projects like shop.local.dev, blog.local.dev, etc., so I would like to separate all this functionality into separate applications with separate databases.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Dmitry, 2017-07-08
@slo_nik

Good afternoon.
Create a virtual host, each with its own document root and server name

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "C:\xampp\htdocs\test\web"
    ServerName test
    ServerAlias www.test
    ErrorLog "logs/test-error.log"
    CustomLog "logs/test-access.log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "C:\xampp\htdocs\test1\web"
    ServerName test1
    ServerAlias www.test1
    ErrorLog "logs/test1-error.log"
    CustomLog "logs/test1-access.log" common
</VirtualHost>

Accordingly, these directories should be created in C:\xampp\htdocs and applications deployed there. Each has its own database, setting via config/web.php in each application.
The addresses to access each project should be:
Although the error
may indicate that you have a problem with the framework itself.
What version are you using?
Does vendor\bower/jquery/dist exist?

N
Nikita, 2017-07-08
@bitver

Delete /vendor & composer.lock

composer global require "fxp/composer-asset-plugin:^1.3.1"
composer install

A
ADA M, 2017-07-08
@adiletmurzaliev

Thanks to all. In fact, the error arose due to the fact that I did not define an alias for the vendor folder:
As a result, I scattered the applications into separate directories. Everything is working. On the input script, I wrote a small code to determine the name of the subdomain, depending on which a separate application will be built. Also created several console applications. I don’t know how correct this is) But in general it’s convenient and works)

M
Maxim Timofeev, 2017-07-09
@webinar

If you need more than 1 application - why then the basic template? What you have done is an advanced template. And it would be rational to take it. There, and take out aliases and a bunch of other things are more correctly implemented for 2 or more applications.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question