Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check vendor folder when using kirby-cms-path: false #11

Open
iskrisis opened this issue Oct 4, 2022 · 4 comments
Open

Check vendor folder when using kirby-cms-path: false #11

iskrisis opened this issue Oct 4, 2022 · 4 comments

Comments

@iskrisis
Copy link

iskrisis commented Oct 4, 2022

When using
composer.json

"extra": {
   "kirby-cms-path": false,
}

the cli fails. I am not sure if "kirby-cms-path" sets the path or you can just use false so it's moved to vendor.

Using kirby.cli.json doesn't seem to help but that is pointing to vendor autoloader so it should not matter where kirby is?

@bastianallgeier
Copy link
Member

Could you check if the version on develop fixes this problem for you? Make sure to run the CLI in the same root as your index.php

@RobertCordes
Copy link

For me this doesn’t work, even with the dev version (dev-main 9182f92). I have also tried using the kirby.cli.json but with no luck.

@iamwebrocker
Copy link

iamwebrocker commented Oct 7, 2022

perhaps related… I have

Solved, see update below [1]

"extra": {
    "kirby-cms-path": "htdocs/kirby"
  }

in the composer.json.

and this directory structure:

<myabspath>
  composer.json
  -- htdocs
    .htaccess
    index.php
    -- kirby
    -- site
    ...

If I run the Kirby Cli in the directory where the composer.json is, it works - showing the possible commands.
Now when I run kirby clear:cache for example, The Kirby installation could not be found is returned.

If I change into the "htdocs" directory (where the index.php and .htaccess etc "live"), and run the cli there, I get

PHP Warning:  require_once(/<myabspath>/htdocs/kirby/vendor/autoload.php): Failed to open stream: No such file or directory in /.config/composer/vendor/getkirby/cli/bin/kirby on line 17

Warning: require_once(/<myabspath>/htdocs/kirby/vendor/autoload.php): Failed to open stream: No such file or directory in /.config/composer/vendor/getkirby/cli/bin/kirby on line 17
PHP Fatal error:  Uncaught Error: Failed opening required '/<myabspath>/htdocs/kirby/vendor/autoload.php' (include_path='.:/usr/share/php:..') in /.config/composer/vendor/getkirby/cli/bin/kirby:17
Stack trace:
#0 /.config/composer/vendor/bin/kirby(120): include()
#1 {main}
  thrown in /.config/composer/vendor/getkirby/cli/bin/kirby on line 17

Fatal error: Uncaught Error: Failed opening required '/<myabspath>/htdocs/kirby/vendor/autoload.php' (include_path='.:/usr/share/php:..') in /.config/composer/vendor/getkirby/cli/bin/kirby:17
Stack trace:
#0 /.config/composer/vendor/bin/kirby(120): include()
#1 {main}
  thrown in /.config/composer/vendor/getkirby/cli/bin/kirby on line 17

I added a kirby.cli.json parallel to the composer.json, with

{
    "roots": {
        "index": "./htdocs",
    }
}

And then this error happens

PHP Fatal error:  Uncaught TypeError: Kirby\CLI\CLI::createOptions(): Return value must be of type array, null returned in /.config/composer/vendor/getkirby/cli/src/CLI/CLI.php:279
Stack trace:
#0 /.config/composer/vendor/getkirby/cli/src/CLI/CLI.php(43): Kirby\CLI\CLI->createOptions()
#1 /.config/composer/vendor/getkirby/cli/src/CLI/CLI.php(101): Kirby\CLI\CLI->__construct()
#2 /.config/composer/vendor/getkirby/cli/bin/kirby(23): Kirby\CLI\CLI::command()
#3 /.config/composer/vendor/bin/kirby(120): include('/.config/compos...')
#4 {main}
  thrown in /.config/composer/vendor/getkirby/cli/src/CLI/CLI.php on line 279

Fatal error: Uncaught TypeError: Kirby\CLI\CLI::createOptions(): Return value must be of type array, null returned in /.config/composer/vendor/getkirby/cli/src/CLI/CLI.php:279
Stack trace:
#0 /.config/composer/vendor/getkirby/cli/src/CLI/CLI.php(43): Kirby\CLI\CLI->createOptions()
#1 /.config/composer/vendor/getkirby/cli/src/CLI/CLI.php(101): Kirby\CLI\CLI->__construct()
#2 /.config/composer/vendor/getkirby/cli/bin/kirby(23): Kirby\CLI\CLI::command()
#3 /.config/composer/vendor/bin/kirby(120): include('/.config/compos...')
#4 {main}
  thrown in /.config/composer/vendor/getkirby/cli/src/CLI/CLI.php on line 279

if I run the cli from the root directory. changing into htdocs, the same require_once error as above happens.

I have a second installation where the composer.json, .htaccess, index.php and the kirby directory all are on the same level -- there the cli works fine.

Thanks for the cool new version, aside from the cli hickup described here, it was a very smooth update.

[1] Update: I reconsidered my structure. Why am I having the kirby directory inside my public (htdocs)? I guess this is from some legacy times… anyway I moved the kirby directory one level higher

<myabspath>
  composer.json
  -- kirby
  -- htdocs
    .htaccess
    index.php
    -- site
    ...

and modified the index.php inside htdocs as explained in the docs (https://getkirby.com/docs/cookbook/setup/composer#installing-kirby-to-a-custom-directory), changed the composer.json back to

...
"extra": {
    "kirby-cms-path": "kirby"
  }

ran composer update and now the cli works when called from inside my htdocs dir.

@jensscherbl
Copy link

Had the same issue. With a slightly customized setup and a public docroot inside the main project root, the cli tool only works from within the public docroot, not from the project root.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants