T
T
tigra2016-11-16 16:06:01
Yii
tigra, 2016-11-16 16:06:01

How to host an API in YII2?

Standard structure

| project
  | frontend
  | backend
  | index.php

I want to place the api folder at the level with these folders and in it my modules, controllers and configs, etc.
is it possible? maybe someone saw articles how to implement it?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maxim Timofeev, 2016-11-16
@tigroid3

Copy the backend folder, rename it to api, edit the config and that's it, api is now a separate application with its own config. For full feng shui, take api to a subdomain.
but, index.php is on the same level as backend, etc. this is bad practice, rather like this:
-project
----frontend
----common
----backend
----api
----public_html (public folder accessible from the web)
--------css
--------images
--------index.php
--------admin(admin folder)
------------css
---- --------index.php
--------api (api subdomain folder)
------------index.php (api entry point)

K
Kirill Sharonov, 2016-11-16
@k_sharonov

Create a module.
www.yiiframework.com/doc-2.0/guide-structure-modul...

E
Evgeny Bukharev, 2016-11-16
@evgenybuckharev

| project
| front end
| backend
| API
| api2
| api3
| index.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question