2766

Trouble with local host PHP require_once

Question:

I am hosting a site locally with <strong>MAMP</strong>. I have the virtual host setup properly and the index.php file does get pulled up when i reference the local URL: my.example.local

The issue is that the PHP file includes are not working. Here is a sample of the code:

<?php session_start(); $_SESSION['message'] = ''; require_once "includes/config.php"; require_once "includes/classes/facilities.class.php"; require_once "includes/classes/states.class.php"; $title = "Home"; $sub_title = $title; $reset = false; require_once "includes/header.php"; ?>

and here is the error message i get when accessing index.php:

Warning: require_once(includes/classes/facilities.class.php): failed to open stream: No such file or directory in /Users/userName/IOD/portal/index.php on line 9 Fatal error: require_once(): Failed opening required 'includes/classes/facilities.class.php' (include_path='.:/Applications/MAMP/bin/php/php5.4.10/lib/php') in /Users/userName/IOD/portal/index.php on line 9

For the record I have tried multiple different ways of referencing the file path, relative, absolute, using the host name, etc.

I am willing to try anything but haven't had any luck so far. Oh and before you ask, yes the files are in the referenced location but for some reason the (local)server doesn't seem to think they are.

Note: this works fine on the web server, I was trying to host it locally to implement version control so I can Dev locally and push changes to the server.

Answer1:

If you put your include/ folder into this folder;

/Users/jfloyd/IOD/includes/<all in here>

Then alter this line in your PHP ini from:

include_path='.:/Applications/MAMP/bin/php/php5.4.10/lib/php'

TO

include_path='.:/Applications/MAMP/bin/php/php5.4.10/lib/php:/Users/jfloyd/IOD/'

Then save the file and restart your server, then the include files should be found.

This ini directive can be set in any number of places, in each file, in each folder using .htaccess or in httpd.conf or in the ini file, as I just described.

Recommend

  • JHipster Entity Generator crahing
  • Getting a line that has the coordinates defined by the mouse location
  • Embedding a Google map
  • How to force Composer to download a local package?
  • Is it possible to send skype chat messages from a linux server without X?
  • How to extract a number from a string [duplicate]
  • Javascript focus remove text highlight
  • PHP Listener Script for Paypal Webhooks
  • Installing Perl6 and Panda on Ubuntu 15.10. Problems with bootstrap.pl
  • Can my PDF ping my server when it is opened?
  • Multiple producers single consumer locking schema
  • Tell Git to stop prompting me for conflicts when none really exist?
  • Android full screen on only one activity?
  • MongoDB in PHP using aggregate to group by _id is null not working
  • How can I send an e-mail from a vbs script
  • Display issues when we change from one jquery mobile page to another in firefox
  • Align navbar back button on right side
  • Accessing IRQ description array within a module and displaying action names
  • How to add date and time under each post in guestbook in google app engine
  • How to set/get protobuf's extension field in Go?
  • DirectX11 ClearRenderTargetViewback with transparent buffer?
  • Validaiting emails with Net.Mail MailAddress
  • sending/ receiving email in Java
  • Javascript + PHP Encryption with pidCrypt
  • To display the title for the current loaction in map in iphone
  • Web-crawler for facebook in python
  • Akka Routing: Reply's send to router ends up as dead letters
  • Cannot Parse HTML Data Using Android / JSOUP
  • InvalidAuthenticityToken between subdomains when logging in with Rails app
  • trying to dynamically update Highchart column chart but series undefined
  • Getting Messege Twice Using IMvxMessenger
  • Java static initializers and reflection
  • Bitwise OR returns boolean when one of operands is nil
  • unknown Exception android
  • sending mail using smtp is too slow
  • costura.fody for a dll that references another dll
  • Binding checkboxes to object values in AngularJs
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • Unable to use reactive element in my shiny app