P
P
Padre2017-07-15 08:08:46
PHP
Padre, 2017-07-15 08:08:46

Is it possible to change the web folder in Yii2?

The framework itself in Yii2 is installed in a folder, and if the server looks in the same folder, then we do htaccess and requests are redirected to the web folder, which contains all the files accessible from the web. Question: is it possible to change the name of the web folder, for example, to public_html, do I need to change the framework settings after that and which ones?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sorokinfil, 2019-01-21
@thisuserhatephp

I'll write it the old fashioned way, I don't remember what it's like in prepare. tbl_1 and tbl_2 correspond to the order in which the pictures are displayed, you need to replace them with the names of your tables.

// Создаём переменную, в которую будем заносить инфу из БД
$your_list = [];
// Получаем id и username всех пользователей из tbl_1, id которых встречаются в tbl_2
$query = $dbpdo->query
("
  SELECT tbl_1.user_id, tbl_1.username
  FROM tbl_1
  INNER JOIN tbl_2 ON tbl_2.id = tbl_1.user_id
");
// Извлекаем, формируем двумерный массив
while ($user = mysqli_fetch_assoc ($query))
  $your_list[] = $user;
// Выводим через echo
foreach ($your_list as $user)
  echo $user['user_id'] . ': ' . $user['username'] . '<br />';

D
Decadal, 2017-07-15
@yii16

you only need to change the DocumentRoot in your server settings. This is all thanks to the alias used in yii2, and any mention of the web folder has been replaced with @webroot alias.
And it is declared in the core of the framework like this:
i.e., from where index.php was launched, there will be a folder that plays the role of the web folder.
More details: yii\web\Application class sources.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question