Is it OK to include files using ABSPATH?

get_home_path() only works when WP admin scripts are loaded.

ABSPATH is defined in wp-config.php so works anytime after the config file is loaded, so it should be totally fine for your use.

It is set to the dirname(__FILE__) + trailing slash of wp-load.php (same location as e.g. wp-config.php). dirname here returns the absolute path where WordPress is installed. For example, /home/user/public_html and ABSPATH adds a trailing slash

/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
    define('ABSPATH', dirname(__FILE__) . "https://wordpress.stackexchange.com/");

// So,
ABSPATH == '/home/user/public_html/'; // WP files are in public_html

So if you have a folder structure such as this:

- public_html/
- - wp-admin/
- - wp-content/
- - wp-includes/
- - wp-config.php
- - wp-load.php
- - vendor/
- - - autoload.php
- ...

You can put the following in your theme’s functions.php file to load the autoload.php file

require_once( ABSPATH . 'vendor/autoload.php' );

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)