1

I inherited a site running craft and I was asked to move it to my server to host it. The other developer zipped the files and made a database dump for me.

Usually, when I move a site, they have Cpanel access, so I just move and it works with a few tweaks, but they didn't have Cpanel and I am in over my head.

I Know I haven't provided a lot to go on, as I don't know what you need to help me. What is a common thing overlooked? I can post error messages if it helps. The main one I get is the following:

[15-Sep-2020 13:22:01 UTC] PHP Warning:  Use of undefined constant _DIR_ - assumed '_DIR_' (this will throw an Error in a future version of PHP) in /home/client/public_html/index.php on line 7

[15-Sep-2020 13:22:01 UTC] PHP Warning:  require_once(./home/client//vendor/autoload.php): failed to open stream: No such file or directory in /home/client/public_html/index.php on line 11

[15-Sep-2020 13:22:01 UTC] PHP Fatal error:  require_once(): Failed opening required './home/client//vendor/autoload.php' (include_path='.:/opt/cpanel/ea-php74/root/usr/share/pear') in /home/client/public_html/index.php on line 11
2
  • Could you post the content of your index.php file? – nstCactus Sep 15 '20 at 14:01
  • <?php /** * Craft web bootstrap file */ // Set path constants define('CRAFT_BASE_PATH', dirname(DIR) . '/home/client'); define('CRAFT_VENDOR_PATH', CRAFT_BASE_PATH.'/vendor'); // Load Composer's autoloader require_once CRAFT_VENDOR_PATH.'/autoload.php'; // Load dotenv? if (class_exists('Dotenv\Dotenv') && file_exists(CRAFT_BASE_PATH.'/.env')) { Dotenv\Dotenv::create(CRAFT_BASE_PATH)->load(); } // Load and run Craft define('CRAFT_ENVIRONMENT', getenv('ENVIRONMENT') ?: 'production'); $app = require CRAFT_VENDOR_PATH.'/craftcms/cms/bootstrap/web.php'; $app->run(); – xecutech Sep 15 '20 at 14:04
2

The main issue is that the require_once CRAFT_VENDOR_PATH.'/autoload.php'; fails.

This is because the DIR constant, used to compute the value of CRAFT_BASE_PATH and CRAFT_VENDOR_PATH is undefined.

Try to define the value of the DIR constant so that CRAFT_VENDOR_PATH points to the vendor directory in your Craft project (it hard to help you further without knowing your directory structure).

Once this is done, as Jamie mentions, you must use composer to install Craft dependencies.

Did you make any changes to the index.php file of is it just like it was in the archive you received from the other dev?

2
  • I edited the index.php because the original developer deleted the settings. I think they were being a pain on purpose. Is the DIR set in a specific location other than index.php? – xecutech Sep 15 '20 at 16:46
  • I don't think so, I think the important constants are CRAFT_BASE_PATH and CRAFT_VENDOR_PATH. Can you post the the content of your project root? – nstCactus Sep 15 '20 at 17:54
1

Craft comes with a vendor directory were all your extras and plugins are stored, and the content of it is installed through the composer craft setup, as the contents is stored in your composer.json.

I'd make sure you read this thoroughly: https://craftcms.com/docs/3.x/installation.html#step-1-download-craft

You can also go to this url to install craft through your browser rather than terminal, try this http://thisisyourwebaddress/index.php?p=admin/install

If you've got all the craft files, you will be taken to the install process were you can enter the database details and install craft.

5
  • Should I run an install over the files that were already installed before the site was moved? I am wondering if I should do a fresh install and then copy the site template files over? I am really stuck with this mess and I may just have to tell the client I can't complete this for them. I appreciate the help. – xecutech Sep 15 '20 at 14:57
  • I think(If someone who's more knowledgable can correct me) Usually you'd want to just run the install, that and composer install too, it will install everything from your composer.json, from previous experience, after doing this this would usually then show you the error "HTTP 503 – Service Unavailable". which displays on a craft template, which means you need the correct database details – Jamie Sep 15 '20 at 15:38
  • Also looking at your errors, it looks like the paths in your index.php may be slightly out giving you the errors. Find your autoload.php etc and make sure those paths match up and reflect your project! for example "/home/client//vendor/autoload.php". this has client//vendor with two forward slashes. – Jamie Sep 15 '20 at 15:53
  • I changed the index.php to correct the double slashes. I am starting to wonder if this may be a folder permission issue. – xecutech Sep 15 '20 at 15:56
  • Usually it will tell you if it cannot write somewhere. You should refer to this craftcms.com/docs/3.x/installation.html#directory-structure Lets you know which & where craft needs to write :) – Jamie Sep 15 '20 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.