YaWK / yawk.io

YaWK - Yet another Web Kit [work in progress]
https://yawk.io
MIT License
9 stars 2 forks source link

dbconfig.php file is missing? / Unable to install / Setup Problem #373

Closed ernestbuffington closed 1 year ago

ernestbuffington commented 1 year ago

Fatal error: Uncaught mysqli_sql_exception: Access denied for user ''@'localhost' (using password: NO) in /home/yawk/public_html/system/classes/db.php:46 Stack trace: #0 /home/yawk/public_html/system/classes/db.php(46): mysqli->__construct(NULL, NULL, NULL, NULL, NULL) #1 /home/yawk/public_html/system/classes/db.php(71): YAWK\db->connect() #2 /home/yawk/public_html/system/classes/settings.php(472): YAWK\db->query('SELECT value FR...') #3 /home/yawk/public_html/system/classes/language.php(50): YAWK\settings::getSetting(Object(YAWK\db), 'frontendLanguag...') #4 /home/yawk/public_html/index.php(69): YAWK\language->init(Object(YAWK\db), 'frontend') #5 {main} thrown in /home/yawk/public_html/system/classes/db.php on line 46

YaWK commented 1 year ago

@ernestbuffington

First of all, thank you for cloning, trying, and posting about your experience with YaWK. I'm sorry to hear that you've encountered some difficulties with it. To assist you or benefit from this issue: could you please provide some information?

Have you installed YaWK correctly? On which system (Apache? Nginx?) are you attempting to run YaWK?

The setup routine should generate dbconfig.php during the installation process. Typically, when you clone YaWK and open the URL in your browser, you should see the installer and be guided through five installation steps (select your language, setting up the database, adding project information, adding admin information, and finally, logging into the admin panel).

If the installer does not show up, there could be several reasons:

However, I have labeled this as a bug because this fatal error should be caught rather than visible to the user. Improving the installer process is still on the to-do list, and I will prioritize it as soon as possible. I will take care of it.

ernestbuffington commented 1 year ago

At first, it did load the install page but failed before it ever installed the database. After 1st run a white page after a refresh to try and run the install again.

I tried multiple versions of PHP on a remote Developer server. The server is running Apache 2, php-fpm. Everything runs as the current user. I currently have gzip off.

I am running all versions of PHP so I normally test them all on every project. My resting PHP version is 8.1.15

The db.php file was looking for dbconfig.php in the setup/classes folder which did not exist. I thought it odd that in the db.php file, the include did specify a path to said file. This led me to believe that maybe one also resided in the root.

       /**
         * db constructor - Include the database config file
         */
        public function __construct()
        {   // include config array
            require_once ("dbconfig.php");
        }

So I created one myself after I looked at the following page. https://docs.yawk.io/dbconfig_8php.html

I also put this file in the root hoping maybe it would not keep getting an error every time it hit line: 46 of the db.php file. It of course was looking at the database port when it hit that line which also seemed odd. It was odd because it seems as though it was able to get the server, username, password, and dbname beforehand. I am sure the error was where it passed the data and the string to the connection. It was not returning the correct information so I assume it was not able to get said information.

Keeping gzip off is a common practice among coders so none of them are currently configured to use gzip.

gzip should be an option of course one that I have never used.

I am not a novice programmer, the 1st thing I considered doing was re-writing the database connecter. That was only because I am not familiar with what is going on everywhere in the code yet.

This all stems from the fact that the setup could not find the correct files.

By default, all scripts running as the user on my server have permission to write or make files within the current user's domain. There are many things to consider when using paths in any version of PHP above 7.4. So I figured I would point at that in your repo the file dbconfig.php appeared to be missing.

Also following was the error on line: 71: if ($this->connection = $this->connect())

Leading me to believe this question should be structured around how do I fix the connection and what am I doing wrong with the config.

YaWK commented 1 year ago

Hi @ernestbuffington

dbconfig.php is not available in the repo, as it is generated during the setup process. However, it resides in system/classes/dbconfig.php

The content of this file will look like this:

<?php
    $this->config['server'] = "YOUR DB SERVER";
    $this->config['username'] = "DB USERNAME";
    $this->config['password'] = "DB PASSWORD";
    $this->config['dbname'] = "DB TABLE";
    $this->config['prefix'] = "cms_";
    $this->config['port'] = "3306";
?>

YaWK works with PHP 7+ (developed on 8.x) and you can enable error reporting or check log files for issues. Currently, there is no check during the setup process to verify if the database credentials are correct. However, this feature will be added soon. So, if you are running the Setup, make sure the entered data is accurate. The data import process should only take a few seconds to complete. Once this is done, you will be asked to enter additional details about your website.

I hope this information helps you to resolve the problem.

I will take care of the setup routine and the installation process as soon as possible, hopefully within the next two weeks.

ernestbuffington commented 1 year ago

Is this file also generated during the installation? $filePointer = "system/setup/yawk_database.sql_filepointer";

YaWK commented 1 year ago

Is this file also generated during the installation? $filePointer = "system/setup/yawk_database.sql_filepointer";

maybe temporary, during the database import. I will have a look at it soon.

Improve Installer / Setup Routine

ernestbuffington commented 1 year ago

Thank you Daniel

ernestbuffington commented 1 year ago

I got it working and added you to the CodersExchange Network. https://yawk.coders.exchange

YaWK commented 1 year ago

Implemented XHR database credentials check during setup routine with commit #374. Huge usability improvement.

YaWK commented 1 year ago

Add file & folder checks during setup with commit #375

YaWK commented 1 year ago

378 improved visual appearance of the setup process

YaWK commented 1 year ago

265 added low-level contextual help via tooltips to every single setup element

YaWK commented 1 year ago

380 avoid that setup will crash if interrupted / restarted; added auto-reset database if installation was aborted or faulty. As long as it is not finished, setup can be re-started at any time. (at least until it is finished, then the installer will be deleted)

YaWK commented 1 year ago

Thanks to the valuable hints from @ernestbuffington , I've added a lot of features to the installer, fixed numerous issues, and improved overall usability. The installer now checks database credentials, sets mandatory fields, and implements form validation, ensuring that setup should not crash anymore. I have tested these improvements on both Apache and Nginx with PHP 8.1, and I can confirm that the setup process has been significantly improved. Setup process improvement is now complete.

YaWK commented 1 year ago

overall view of what has been done:

Setup Improvement List: Milestone / closed Issues