I store my WordPress theme in my Dropbox to use it easily on many machines. Unfortunately require_once()/include_once() doesn't seem to work for me.
Is store original theme at G:\Dropbox\Dropbox\Wordpress\Themes\Blabla\
The symlink is placed at C:\xampp\htdocs\blabla\wp-content\themes\Blabla
When I wanted to require/include any file, eg. C:\xampp\htdocs\blabla\wp-load.php I used to do require_once('../../wp-load.php');
But with symlink all I got is:
Warning: require_once(../../../wp-load.php): failed to
open stream: No such file or directory in
G:\Dropbox\Dropbox\Wordpress\Themes\Blabla\foo\bar.php on line
2 Fatal error: require_once(): Failed
opening required '../../../wp-load.php'
(include_path='.;C:\xampp\php\PEAR') in
G:\Dropbox\Dropbox\Wordpress\Themes\Blabla\foo\bar.php on line
2
Looks like require_once looks for the file within the Dropbox, not symlink context? Is it possible to fix it somehow? I can't use absolute path as I develop on different machines / different OSes and those vary... Any ideas? How does require_once work when it's symlinked? Does it look for required file in both places (original-context & symlink-context)?
How about putting the original file into you Wordpress folder and symlinking to dropbox?
While installing this, you should turn off dropbox on all machines where you did not move the folder yet.
Related
I am struggling trying to figure out why my require path link is not working.
My folder setup is the following:
Main domain on server test.example.com.
public_html -> test.example.com -> PHPMailer -> PHPMailerAutoload.php
Since the main domain is test.example.com, I am putting test.example.com in the path url. I have to do this for any link on the site (it was a setup mistake, but I haven't changed it yet).
The way I am trying to access this folder is below:
require 'test.example.com/test.example.com/PHPMailer-master/PHPMailerAutoload.php';
I get the following errors:
Warning: require(test.example.com/PHPMailer-master/PHPMailerAutoload.php): failed to open stream: No such file or directory in /home/example/public_html/test.example.com/php/newsletterSend.php on line 4
Warning: require(test.example.com/test.example.com/PHPMailer-master/PHPMailerAutoload.php): failed to open stream: No such file or directory in /home/example/public_html/test.example.com/php/newsletterSend.php on line 4
Fatal error: require(): Failed opening required 'test.example.com/test.example.com/PHPMailer-master/PHPMailerAutoload.php' (include_path='.:/opt/cpanel/ea-php71/root/usr/share/pear') in /home/example/public_html/test.example.com/php/newsletterSend.php on line 4
I need the link to be an absolute path because the file will be used in different folders.
Does anyone see what I am doing wrong?
it looks like your php is in a directory above the phpMailer folder.. so i think the path would be "../PHPMailer/PHPMailerAutoload.php"
you can use absolute paths if its simpler:
/home/foo/public_html/test.example.com/PHPMailer/PHPMailerAutoload.php
or relative paths if you know where you're starting!
../PHPMailer/PHPMailerAutoload.php
I have recently made an API now for that api i have made a subdomain however it broke my php file includes
include $_SERVER['DOCUMENT_ROOT'].'/core/init.php';
now my subdomain i am using is api.website.com and i need to include something from website.com when i try to include its giving the root of the subdomain,
Summary
When i try to include init.php i get
Warning: include(/home/website/public_html/API/core/init.php): failed to open stream: No such file or directory in /home/website/public_html/api/apex/getusers.php on line 2
When i actually need
Warning: include(/home/website/public_html/core/init.php): failed to open stream: No such file or directory in /home/website/public_html/api/apex/getusers.php on line 2
I apologize for my grammar if need be.
Changing your include path to
include ("../../core/init.php");
will fix your problem. However, this is not a recommended approach.
You should think about using a dependency manager like composer. ( https://getcomposer.org/ ). Then your included files will always be under a directory like
/home/website/public_html/vendor/core
and there will be less of a chance of your application breaking if the files in /home/website/public_html/core change.
This should work.
include("../core/init.php");
Use following code
include_once $_SERVER['DOCUMENT_ROOT'] . '/../core/init.php';
visit https://developer.hyvor.com/php/including-files-in-root-with-subdomain.php to learn more.
Currently I have the following structure
httpdocs
- system
- templates
Inside templates I have the following line
require_once(__DIR__.'/../system/config.php');
I get the following error
Warning: require_once(/var/www/vhosts/domain/httpdocs/templates/../system/config.php): failed to open stream: No such file or directory in /var/www/vhosts/domain/httpdocs/templates/header.php on line 8
Fatal error: require_once(): Failed opening required '/var/www/vhosts/domain/httpdocs/templates/../system/config.php' (include_path='.:') in /var/www/vhosts/domain/httpdocs/templates/header.php on line 8
As you can see in the path it just adds the two dots (../) as if it is part of the path, while I meant it to go up one level. Is there a PHP setting required to support relative paths or something?
I tried all possible variants of the path in- and excluding the DIR magic constant to no avail. And yes, config.php is present in system.
Deeply ashamed. After I moved the page to another server, I had changed the name of the system folder.
I have migrated my site to another host (Cloud host); the new host is configured and tested with no issues. However, after copied all files from the old host the wp-admin is stopped responding and I am stuck there. one more thing, the below error is appearing in the homepage. any idea?
Warning: include(/home5/dndrhcom/public_html/3indubai/wp-content/plugins/wp-super-cache/wp-cache-base.php): failed to open stream: No such file or directory in /srv/users/serverpilot/apps/wordpress/public/wp-content/plugins/wp-super-cache/wp-cache.php on line 65
Warning: include(): Failed opening '/home5/dndrhcom/public_html/3indubai/wp-content/plugins/wp-super-cache/wp-cache-base.php' for inclusion (include_path='.:/opt/sp/php5.6/lib/php') in /srv/users/serverpilot/apps/wordpress/public/wp-content/plugins/wp-super-cache/wp-cache.php on line 65
Warning: include_once(/home5/dndrhcom/public_html/3indubai/wp-content/plugins/wp-super-cache/ossdl-cdn.php): failed to open stream: No such file or directory in /srv/users/serverpilot/apps/wordpress/public/wp-content/plugins/wp-super-cache/wp-cache.php on line 82
Warning: include_once(): Failed opening '/home5/dndrhcom/public_html/3indubai/wp-content/plugins/wp-super-cache/ossdl-cdn.php' for inclusion (include_path='.:/opt/sp/php5.6/lib/php') in /srv/users/serverpilot/apps/wordpress/public/wp-content/plugins/wp-super-cache/wp-cache.php on line 82
solved by removed all .php files and add fresh files from new wordpress folder then only edit the links to be leading to my site. thanks a lot
I had a similar problem loading css from a theme directory after a migration and also using serverpilot. The include_path was set to the php install directory, so I solved the problem by adding get_template_directory() to the include.
<?php include '/style.css'; ?>
~~~~~Changed to ~~~~~~~~~~~~~~~
<?php include( get_template_directory() . '/style.css'); ?>
Looks like you might be able to do something similar for plugins.
https://codex.wordpress.org/Function_Reference/plugin_dir_path#Examples
If you uploaded your files with your root#xx.xx.xx.xx user, the file permissions are different to uploading with the serverpilot#xx.xx.xx.xx user.
I had a very similar issue until i removed the files uploaded by root, and re-uploaded with serverpilot.
just change path config file (wp-config.php) change path.
You can find Defien path for this just change your hosting path
define( 'WPCACHEHOME',your hostng path);
This will work fine.
I am trying to run 2 example of PHPExcel
01simple-download-xlsx.php and 07reader.php
01simple-download-xlsx.php Working Perfect but this example 07reader.php is showing error mentioned below Why can't understand since last 4 hours.
Any one can kindly tell me why this is happening when the file is using same directory structure.
Warning: require_once(../Classes/PHPExcel/IOFactory.php): failed to
open stream: No such file or directory in
C:\xampp\htdocs\manazeschool\software\office_admin\exam_excel\Examples\07reader.php
on line 37
Fatal error: require_once(): Failed opening required
'../Classes/PHPExcel/IOFactory.php'
(include_path='.;C:\xampp\php\PEAR') in
C:\xampp\htdocs\manazeschool\software\office_admin\exam_excel\Examples\07reader.php
on line 37
Some of the examples (such as the 01* files) correctly use an absolute pathname __DIR__ . '../Classes/...' to include the main PHPExcel library, which means you don't need to be in the /Examples directory to run them.
Other examples (07reader.php included) simply use a relative pathname '../Classes/...'to include the main PHPExcel library, which means you do need to be in the /Examples directory to run them.
To resolve the issue, either ensure that you're in the /Examples folder when you run these files, or modify the include to use the absolute pathname.
I believe I've now fixed all of these example files to use the absolute pathname in the development branch on github.