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

php leaf not working from any other directory #12

Open
golles opened this issue Oct 14, 2023 · 6 comments
Open

php leaf not working from any other directory #12

golles opened this issue Oct 14, 2023 · 6 comments

Comments

@golles
Copy link

golles commented Oct 14, 2023

Describe the bug
The project leaf (php) file cannot be executed from any other directory.
I realized this when I wanted to set up some commands in cron.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new project with leaf create newleaf (choose MVC)
  2. run php newleaf/leaf
  3. You will get the following error:
PHP Warning:  Undefined array key "database" in /home/golles/workspace/newleaf/vendor/leafs/mvc-core/src/Core.php on line 79
PHP Warning:  Undefined array key "auth" in /home/golles/workspace/newleaf/vendor/leafs/mvc-core/src/Core.php on line 79
PHP Warning:  Undefined array key "connections" in /home/golles/workspace/newleaf/vendor/leafs/mvc-core/src/Database.php on line 43
PHP Warning:  Trying to access array offset on value of type null in /home/golles/workspace/newleaf/vendor/leafs/mvc-core/src/Database.php on line 43
PHP Fatal error:  Uncaught TypeError: Illuminate\Database\Capsule\Manager::addConnection(): Argument leafsphp/leaf#1 ($config) must be of type array, null given, called in /home/golles/workspace/newleaf/vendor/leafs/mvc-core/src/Database.php on line 43 and defined in /home/golles/workspace/newleaf/vendor/illuminate/database/Capsule/Manager.php:119
Stack trace:
#0 /home/golles/workspace/newleaf/vendor/leafs/mvc-core/src/Database.php(43): Illuminate\Database\Capsule\Manager->addConnection()
leafsphp/leaf#1 /home/golles/workspace/newleaf/leaf(43): Leaf\Database::connect()
leafsphp/leaf#2 {main}
  thrown in /home/golles/workspace/newleaf/vendor/illuminate/database/Capsule/Manager.php on line 119

Expected behavior
I would expect, independent the folder you are in, that this file could be executed.

Additional context
For now, I created leaf.sh to allow to run leaf commands by corn triggers.

#!/usr/bin/env bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

cd $SCRIPT_DIR
php leaf $1
@mychidarko mychidarko transferred this issue from leafsphp/leaf Oct 14, 2023
@mychidarko
Copy link
Member

@golles I'll check out this issue. In the meantime, you can use the php leaf script from inside the app directory

@golles
Copy link
Author

golles commented Oct 14, 2023

I don't have a leaf in the app folder.

[user@host app]$ ls -lah
totaal 36K
drwxrwxr-x  9 u31214p25867 u31214p25867 4,0K sep  4 16:34 .
drwxr-xr-x 13 u31214p25867 u31214p25867 4,0K okt 14 12:46 ..
drwxrwxr-x  2 u31214p25867 u31214p25867 4,0K okt 14 00:48 console
drwxrwxr-x  2 u31214p25867 u31214p25867 4,0K sep  4 16:34 controllers
drwxrwxr-x  6 u31214p25867 u31214p25867 4,0K jul 30 19:28 database
drwxrwxr-x  2 u31214p25867 u31214p25867 4,0K sep  4 16:34 helpers
drwxrwxr-x  2 u31214p25867 u31214p25867 4,0K okt 14 12:46 models
drwxrwxr-x  2 u31214p25867 u31214p25867 4,0K okt 14 12:46 routes
drwxrwxr-x  2 u31214p25867 u31214p25867 4,0K sep  4 16:34 views

@mychidarko
Copy link
Member

Sorry, I meant the root directory of your application. There should be a leaf script in there

@golles
Copy link
Author

golles commented Oct 15, 2023

Indeed, that only works if I run it from that directory. I've also tried to run it from any project directory eg, app, php ../leaf that gives the same error.

@mychidarko
Copy link
Member

Is there any reason you're trying to run it from a different directory? The actual intent of that file is to be run from your project directory

@golles
Copy link
Author

golles commented Oct 15, 2023

Yes, I intend to run commands by cron

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

2 participants