hiqdev / hisite-template

HiSite Project Template
https://hisite.hiqdev.com/
BSD 3-Clause "New" or "Revised" License
16 stars 2 forks source link

Unable to run hidev deploy #1

Open nd4c opened 5 years ago

nd4c commented 5 years ago

I followed the instructions on how to install.

When running hidev deploy I get the following error:

$ ./vendor/bin/hidev deploy Created dir: ./public/ Created dir: ./public/assets/ chmod ./public/assets '0777' Couldn't read file: ./public/index.php Written file: ./public/index.php Couldn't read file: ./public/robots.txt Written file: ./public/robots.txt Copied file: ./public/favicon.ico Created dir: ./var/ Created dir: ./var/tmp/ chmod ./var/tmp '0777' chmod ./runtime '0777' Exception: no env file at /var/www/html/yii2_hisite/.env.dist in /var/www/html/yii2_hisite/vendor/hiqdev/hidev-webapp/src/components/Deployer.php:29 Stack trace:

0 /var/www/html/yii2_hisite/vendor/hiqdev/hidev-webapp/src/console/DeployController.php(23): hidev\webapp\components\Deployer->__construct('/var/www/html/y...')

1 [internal function]: hidev\webapp\console\DeployController->actionIndex(NULL, 'all')

2 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)

3 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)

4 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/console/Controller.php(164): yii\base\Controller->runAction('', Array)

5 /var/www/html/yii2_hisite/vendor/hiqdev/hidev/src/console/CommonController.php(39): yii\console\Controller->runAction('', Array)

6 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/base/Module.php(528): hidev\console\CommonController->runAction('', Array)

7 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('deploy', Array)

8 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('deploy', Array)

9 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(hidev\components\Request))

10 /var/www/html/yii2_hisite/vendor/hiqdev/hidev/bin/hidev(19): yii\base\Application->run()

11 /var/www/html/yii2_hisite/vendor/hiqdev/hidev/bin/hidev(22): {closure}()

12 {main}

Exception 'Exception' with message 'no env file at /var/www/html/yii2_hisite/.env.dist'

in /var/www/html/yii2_hisite/vendor/hiqdev/hidev-webapp/src/components/Deployer.php:29

Stack trace:

0 /var/www/html/yii2_hisite/vendor/hiqdev/hidev-webapp/src/console/DeployController.php(23): hidev\webapp\components\Deployer->__construct('/var/www/html/y...')

1 [internal function]: hidev\webapp\console\DeployController->actionIndex(NULL, 'all')

2 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)

3 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)

4 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/console/Controller.php(164): yii\base\Controller->runAction('', Array)

5 /var/www/html/yii2_hisite/vendor/hiqdev/hidev/src/console/CommonController.php(39): yii\console\Controller->runAction('', Array)

6 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/base/Module.php(528): hidev\console\CommonController->runAction('', Array)

7 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('deploy', Array)

8 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('deploy', Array)

9 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(hidev\components\Request))

10 /var/www/html/yii2_hisite/vendor/hiqdev/hidev/bin/hidev(19): yii\base\Application->run()

11 /var/www/html/yii2_hisite/vendor/hiqdev/hidev/bin/hidev(22): {closure}()

12 {main}

nd4c commented 5 years ago

Follow up. [ ] I copied the .env.example to .env.dist [ ] I edited the .env.dist to match the project name: yii2_hisite

Now I get a new error when running hidev deploy: $ ./vendor/bin/hidev deploy Exception: no docker-compose file: core/docker-compose.yml.dist in /var/www/html/yii2_hisite/vendor/hiqdev/hidev-webapp/src/components/Deployer.php:142 Stack trace:

0 /var/www/html/yii2_hisite/vendor/hiqdev/hidev-webapp/src/components/Deployer.php(119): hidev\webapp\components\Deployer->findDocker()

1 /var/www/html/yii2_hisite/vendor/hiqdev/hidev-webapp/src/components/Deployer.php(109): hidev\webapp\components\Deployer->symlinks()

2 /var/www/html/yii2_hisite/vendor/hiqdev/hidev-webapp/src/components/Deployer.php(104): hidev\webapp\components\Deployer->all()

3 /var/www/html/yii2_hisite/vendor/hiqdev/hidev-webapp/src/console/DeployController.php(25): hidev\webapp\components\Deployer->call('all')

4 [internal function]: hidev\webapp\console\DeployController->actionIndex(NULL, 'all')

5 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)

6 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)

7 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/console/Controller.php(164): yii\base\Controller->runAction('', Array)

8 /var/www/html/yii2_hisite/vendor/hiqdev/hidev/src/console/CommonController.php(39): yii\console\Controller->runAction('', Array)

9 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/base/Module.php(528): hidev\console\CommonController->runAction('', Array)

10 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('deploy', Array)

11 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('deploy', Array)

12 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(hidev\components\Request))

13 /var/www/html/yii2_hisite/vendor/hiqdev/hidev/bin/hidev(19): yii\base\Application->run()

14 /var/www/html/yii2_hisite/vendor/hiqdev/hidev/bin/hidev(22): {closure}()

15 {main}

Exception 'Exception' with message 'no docker-compose file: core/docker-compose.yml.dist'

in /var/www/html/yii2_hisite/vendor/hiqdev/hidev-webapp/src/components/Deployer.php:142

Stack trace:

0 /var/www/html/yii2_hisite/vendor/hiqdev/hidev-webapp/src/components/Deployer.php(119): hidev\webapp\components\Deployer->findDocker()

1 /var/www/html/yii2_hisite/vendor/hiqdev/hidev-webapp/src/components/Deployer.php(109): hidev\webapp\components\Deployer->symlinks()

2 /var/www/html/yii2_hisite/vendor/hiqdev/hidev-webapp/src/components/Deployer.php(104): hidev\webapp\components\Deployer->all()

3 /var/www/html/yii2_hisite/vendor/hiqdev/hidev-webapp/src/console/DeployController.php(25): hidev\webapp\components\Deployer->call('all')

4 [internal function]: hidev\webapp\console\DeployController->actionIndex(NULL, 'all')

5 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)

6 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)

7 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/console/Controller.php(164): yii\base\Controller->runAction('', Array)

8 /var/www/html/yii2_hisite/vendor/hiqdev/hidev/src/console/CommonController.php(39): yii\console\Controller->runAction('', Array)

9 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/base/Module.php(528): hidev\console\CommonController->runAction('', Array)

10 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('deploy', Array)

11 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('deploy', Array)

12 /var/www/html/yii2_hisite/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(hidev\components\Request))

13 /var/www/html/yii2_hisite/vendor/hiqdev/hidev/bin/hidev(19): yii\base\Application->run()

14 /var/www/html/yii2_hisite/vendor/hiqdev/hidev/bin/hidev(22): {closure}()

15 {main}

hiqsol commented 5 years ago

Sorry, it's under development: no docs and may not work :) I hope I'll have a time to fix it on weekend.

nd4c commented 5 years ago

Yeah, I kind of figured it was more a pastime for you, at least lately. But it really looks like the best way to implement Yii2, especially looking at the plans for Yii3.

It appears to be failing either during or before the creation of the /src/config/bootstrap.php file.

hiqsol commented 5 years ago

it was more a pastime

Not really :) Actually, other way around :) We (at hiqdev) continue working with Yii2 and gone even further. And hopefully I found even a better way of yii2 application deployment.

Do you use docker?

nd4c commented 5 years ago

Sorry, "pastime" was probably not the best word. I'm seriously interested in this project - I agree that it's a better way to deploy a yii2 app.

No, I don't use docker. I realize it's useful, but it was not really needed for development of our inhouse app. I guess I'm kind of old-school. If it's important to the deployment of a hisite version of yii2, then I can look into it.

nd4c commented 5 years ago

I adjusted Deployer.php to allow for no Docker.

When I run deploy I now get:

./vendor/bin/hidev deploy
> ln -sf .env.dist .env
> ln -sf  docker-compose.yml
> sudo chmod a+w runtime public/assets
> mkdir -p .docker/php/var/log/php
> sudo touch .docker/php/var/log/php/php.log
> sudo chmod a+w .docker/php/var/log/php/php.log
> composer dump-autoload
Generating autoload files
Assembling config files  
> sudo cp /tmp/yii2_hisite.service /etc/systemd/system/yii2_hisite.service
> sudo systemctl enable yii2_hisite
Failed to enable unit: Invalid argument
! failed sudo systemctl enable yii2_hisite> sudo systemctl start yii2_hisite
>  systemctl status yii2_hisite
● yii2_hisite.service - yii2_hisite service in Docker container
   Loaded: loaded (/etc/systemd/system/yii2_hisite.service; disabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Mon 2019-10-21 11:11:51 CDT; 7ms ago
  Process: 7947 ExecStart=/usr/local/bin/docker-compose up (code=exited, status=203/EXEC)
 Main PID: 7947 (code=exited, status=203/EXEC)
! failed  systemctl status yii2_hisite

It's still assuming I have Docker and that I want a new service installed. Kind of scarey... And I had to clean up my services.

I had hoped that this would run off my apache (httpd) service like a typical yii2 app. A little closer to the metal.

hiqsol commented 5 years ago

I had hoped that this would run off my apache (httpd) service like a typical yii2 app

Previously we used non-docker setup too, but it was nginx with fpm... You can take a look here: https://github.com/hiqdev/hidev-nginx/

But you know, everybody cooks their web-server their own way. So I think this part of setup better be left to a user.

nd4c commented 5 years ago

I guess I misunderstood the purpose of deploy. I know it's named "deploy" but I assumed it meant building any required files and configuration in the project folder itself to prepare it for deployment.

I don't need to deploy the project (it already is technically setup to run on my dev system) but rather when it runs it fails to find the /src/config/bootstrap.php file. I was expecting deploy to build that.

nd4c commented 5 years ago

I ran hidev install - no feedback, but no errors. I ran hidev check - it created a phpstan.phar file. I ran hidev fix - it told me I can't use php 7.3

hiqsol commented 5 years ago

I guess I misunderstood the purpose of deploy

No :) It's me who put everything to deploy. I'll split it!

nd4c commented 5 years ago

That would nice! Thanks!

nd4c commented 5 years ago

Actually "deploy" would be the place to the call the deployment scripting. Makes sense. You might want to separate the prep scripts to another command, something like "prep" or "setup".

nd4c commented 5 years ago

By the way I believe there's a typo in Deployer, in getHosts(). line 288 should be $hosts = [$_ENV['HOST']];

hiqsol commented 5 years ago

Ok, I've split it into:

For the moment up is specific for my setup. But deploy should be ok.

nd4c commented 5 years ago

Great! Thanks! I'll try it out later today (working).

nd4c commented 5 years ago

Starting from scratch:

$ composer create-project --stability=dev "hiqdev/hisite-template:*" yii2_hisite
Installing hiqdev/hisite-template (dev-master 9836cbaed13a2757fbd8caea5350f6289459676a)
  - Installing hiqdev/hisite-template (dev-master master): Cloning master from cache
Created project in yii2_hisite
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 45 installs, 0 updates, 0 removals
  - Installing yiisoft/yii2-composer (dev-master 6026738): Cloning 602673880e from cache
  - Installing opis/closure (3.4.1): Loading from cache
  - Installing riimu/kit-phpencoder (v2.4.0): Loading from cache
  - Installing hiqdev/composer-config-plugin (dev-master 7fa31d1): Cloning 7fa31d11d2 from cache
  - Installing bower-asset/jquery (3.4.1): Loading from cache
  - Installing cebe/markdown (dev-master eeb1bf6): Cloning eeb1bf622e from cache
  - Installing bower-asset/inputmask (3.3.11): Loading from cache
  - Installing ezyang/htmlpurifier (v4.11.0): Loading from cache
  - Installing bower-asset/yii2-pjax (2.0.7.1): Loading from cache
  - Installing bower-asset/punycode (v1.3.2): Loading from cache
  - Installing yiisoft/yii2 (dev-master 69df729): Cloning 69df72939c from cache
  - Installing hiqdev/php-collection (dev-master 7f7fdac): Cloning 7f7fdacb62 from cache
  - Installing hiqdev/yii2-collection (dev-master 6d7c440): Cloning 6d7c440849 from cache
  - Installing hiqdev/yii2-menus (dev-master 7586e2b): Cloning 7586e2b82c from cache
  - Installing hiqdev/hidev-nginx (dev-master 285ef28): Cloning 285ef28a56 from cache
  - Installing hiqdev/hidev-webapp (dev-master c4cb85e): Cloning c4cb85e71c from cache
  - Installing swiftmailer/swiftmailer (5.x-dev 181b89f): Cloning 181b89f18a from cache
  - Installing yiisoft/yii2-swiftmailer (2.0.7): Loading from cache
  - Installing symfony/polyfill-mbstring (dev-master a874bbf): Cloning a874bbf913 from cache
  - Installing symfony/polyfill-ctype (dev-master 550ebaa): Cloning 550ebaac28 from cache
  - Installing vlucas/phpdotenv (2.6.x-dev 2a7dcf7): Cloning 2a7dcf7e3e from cache
  - Installing hiqdev/hisite (dev-master 6f12f5c): Cloning 6f12f5cd31 from cache
  - Installing bower-asset/bootstrap (v3.4.1): Loading from cache
  - Installing yiisoft/yii2-bootstrap (dev-master 3c49557): Cloning 3c49557ae3 from cache
  - Installing bower-asset/pnotify (2.1.0): Loading from cache
  - Installing hiqdev/yii2-asset-pnotify (dev-master d5bfa39): Cloning d5bfa39fba from cache
  - Installing hiqdev/yii2-pnotify (dev-master 592a500): Cloning 592a5003ce from cache
  - Installing hiqdev/yii2-thememanager (dev-master 63ce3b1): Cloning 63ce3b1338 from cache
  - Installing hiqdev/yii2-language (dev-master 913ea7b): Cloning 913ea7b222 from cache
  - Installing hiqdev/yii2-monitoring (dev-master f93bc1b): Cloning f93bc1bbae from cache
  - Installing hiqdev/yii2-theme-flat (dev-master dc82b5b): Cloning dc82b5b789 from cache
  - Installing yiisoft/yii2-debug (2.1.10): Loading from cache
  - Installing symfony/yaml (4.4.x-dev 13bfb7f): Cloning 13bfb7f246 from cache
  - Installing twig/twig (2.x-dev d073fed): Cloning d073fed7f1 from cache
  - Installing yiisoft/yii2-twig (2.2.1): Loading from cache
  - Installing hiqdev/hidev (dev-master d0e2c44): Cloning d0e2c44a66 from cache
  - Installing hiqdev/hidev-phpstan (dev-master 7f7706f): Cloning 7f7706f976 from cache
  - Installing hiqdev/hidev-chkipper (dev-master 2259678): Cloning 2259678bb7 from cache
  - Installing hiqdev/hidev-travis (dev-master 10292af): Cloning 10292af5cf from cache
  - Installing hiqdev/hidev-scrutinizer (dev-master 24a0818): Cloning 24a0818f8d from cache
  - Installing hiqdev/hidev-composer (dev-master b7b27bf): Cloning b7b27bf0e0 from cache
  - Installing hiqdev/hidev-phpunit (dev-master 53f3567): Cloning 53f3567490 from cache
  - Installing hiqdev/hidev-license (dev-master 99069ad): Cloning 99069ad17e from cache
  - Installing hiqdev/hidev-php-cs-fixer (dev-master f34e82f): Cloning f34e82f2d4 from cache
  - Installing hiqdev/hidev-php (dev-master 90c8d55): Cloning 90c8d55a2e from cache
riimu/kit-phpencoder suggests installing ext-gmp (To convert GMP numbers into PHP code)
symfony/yaml suggests installing symfony/console (For validating YAML files using the lint command)
Writing lock file
Generating autoload files
Assembling config files  
Do you want to remove the existing VCS (.git, .svn..) history? [Y,n]? y

$ cd yii2_hisite

$ ./vendor/bin/hidev deploy
Created dir:  ./public/
Created dir:  ./public/assets/
chmod ./public/assets '0777'
Couldn't read file: ./public/index.php
Written file: ./public/index.php
Couldn't read file: ./public/robots.txt
Written file: ./public/robots.txt
Copied file: ./public/favicon.ico
chmod ./runtime '0777'

I get in my error log:

cat hisite-error.log
[Thu Oct 24 12:58:37.045852 2019] [ssl:warn] [pid 1382] AH01909: hisite.web:443:0 server certificate does NOT include an ID which matches the server name
[Thu Oct 24 12:59:00.199788 2019] [php7:notice] [pid 16279] [client 127.0.0.1:55158] PHP Warning:  require(/var/www/html/yii2_hisite/public/../src/config/bootstrap.php): failed to open stream: No such file or directory in /var/www/html/yii2_hisite/public/index.php on line 3
[Thu Oct 24 12:59:00.199807 2019] [php7:notice] [pid 16279] [client 127.0.0.1:55158] PHP Stack trace:
[Thu Oct 24 12:59:00.199811 2019] [php7:notice] [pid 16279] [client 127.0.0.1:55158] PHP   1. {main}() /var/www/html/yii2_hisite/public/index.php:0
[Thu Oct 24 12:59:00.199819 2019] [php7:notice] [pid 16279] [client 127.0.0.1:55158] PHP Fatal error:  require(): Failed opening required '/var/www/html/yii2_hisite/public/../src/config/bootstrap.php' (include_path='.:/usr/share/php') in /var/www/html/yii2_hisite/public/index.php on line 3
[Thu Oct 24 12:59:00.199822 2019] [php7:notice] [pid 16279] [client 127.0.0.1:55158] PHP Stack trace:
[Thu Oct 24 12:59:00.199827 2019] [php7:notice] [pid 16279] [client 127.0.0.1:55158] PHP   1. {main}() /var/www/html/yii2_hisite/public/index.php:0

So it looks like it's not creating the bootstrap file.

(Note: the SSL warning is just that I'm using cert files that don't match the virtual host names. That's not related at all.)

nd4c commented 5 years ago

By the way. I had run composer update on the previous version of my hisite project and it ran. But, of course, I had copied the bootstrap file from vendor/hiqdev somewhere.

However, the menu links: about, contact, and login failed to find the controller/action.

nd4c commented 5 years ago

I copied over the bootstrap.php file:

<?php

if (!defined('WEBAPP_ROOT_DIR')) {
    define('WEBAPP_ROOT_DIR', dirname(dirname(__DIR__)));
}

$bootstrap = WEBAPP_ROOT_DIR . '/vendor/hiqdev/hidev-webapp/src/bootstrap.php';

if (!file_exists($bootstrap)) {
    fwrite(STDERR, "Run composer to set up dependencies!\n");
    exit(1);
}

require_once $bootstrap;

And the site works, but, again, the menu links do not.

By the way, the differences between the old and new project, other than unique ids: [ ] the LICENSE file has a different copyright date inside [ ] Missing these files: src/config/bootstrap.php .env.dist .php_cs .php-cs-fixer.phar .phpstan.phar [ ] the .scrutinizer.yml and .travis.yml files are slightly different.

nd4c commented 5 years ago

Error handling has some issues: If I click on the menu link for about (https://hisite/site/about) I get a standard html 404 Not Found error: Not Found The requested URL /site/about was not found on this server. Apache/2.4.29 (Ubuntu) Server at hisite Port 443

But if I go to https://hisite/about I get the sites error page: Not Found (#404) Page not found (etc.)

My apache virtual host config file has the following in it (among other settings):

    DocumentRoot /var/www/html/yii2_hisite/public
    <Directory /var/www/html/yii2_hisite/public>
        RewriteEngine on
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . index.php
        RewriteRule ^index.php/ - [L,R=404]
        Options -Indexes +FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
nd4c commented 5 years ago

OK - I fixed the menus... Apparently my apache config had the rewrites in the wrong order... arrgghhh. Need to be:

    RewriteEngine on
    RewriteRule ^index.php/ - [L,R=404]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . index.php
hiqsol commented 5 years ago

I know what to do. I'll update the setup today.

hiqsol commented 5 years ago

Updated

nd4c commented 5 years ago

Is the update been pushed to repo? I just tried from scratch and it's still missing the bootstrap.php file. And if I copy one in the site runs perfect.

hiqsol commented 5 years ago

Did you notice that the entry script was changed to /public/index from /web/index? And the script is symlinked from the hisite package. Please take a look at this manual: https://github.com/hiqdev/hisite-template/blob/master/docs/DirectoryStructure.md