LebGeeks

A community for technology geeks in Lebanon.

You are not logged in.

#1 April 11 2014

ironman
Member

PHP help needed

Hello Guys,

i am about to deliver a PHP project that i assisted in
i just have a problem when deploying it, and the problem is that i had to move all the files to a new folder on the remote server,
and now the project isn't working correctly,
any private help would be appreciated.

Thanks.

Offline

#2 April 11 2014

Johnaudi
Member

Re: PHP help needed

It's better if you post the code (or atleast the part of the code) to public so we can analyze the problem...

Offline

#3 April 11 2014

ironman
Member

Re: PHP help needed

this is the index.php code

<?php

define("DS", DIRECTORY_SEPARATOR);
define("B_ROOT_DIR", __DIR__ . DS);
define('DISPATCHER_DEFINED', true);

include B_ROOT_DIR . 'vendor' . DS . 'autoload.php';
include B_ROOT_DIR . 'utilities' . DS . 'main.php';

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Doctrine\DBAL\Connection;

$app = new Silex\Application();

my project now is inside a directory called 'xxx' let's say, so i tried adding xxx after __DIR__
but it didn't work too

PS: i'm not a developer, am trying to upload the code to a remote web server.

Offline

#4 April 12 2014

rolf
Member

Re: PHP help needed

You are moving the code from one enviroment to another.
Many things can go wrong. "The code is not working" is vague.
You can create a file, call it, for example, "phpinfo.php", and as contents, write this inside it:

<?php phpinfo() ?>

And run it on both environments. It will give you the version, and configuation variables, and you can compare.
Some of the things that can go wrong:
- Different versions of PHP: sometimes it's a problem, sometimes it's not. It depends on the used features
- the database not configured correctly
- some libraries (for example GD2) not being enabled
- using absolute paths and URLs in the code (bad practice)
- using "PHP safe mode", some stupid hosts still do that
- file permission issues in some directories
- short open tags: depeding on the configuation, "<?" will be accepted as an alternative to "<?php" or not...
and other things!

As you may start to guess by now, your best bet is to get in touch with the developer.

Offline

#5 April 12 2014

rtp
Member

Re: PHP help needed

The webserver should log the error inside a file. Check the main directories for a new file (it might be hidden).  You should be able to read the error you are having and debug it.

Offline

#6 April 12 2014

rolf
Member

Re: PHP help needed

To make it display errors in the browser, add this before your code:

error_reporting(E_ALL);
ini_set('display_errors', 1);

It may or may not work, depending on your php.ini
If you're seeing too many notices, try changing "E_ALL" to "E_ALL ^ E_NOTICE" (show all error messages except notices).

Last edited by rolf (April 12 2014)

Offline

#7 April 12 2014

ironman
Member

Re: PHP help needed

@rolf , @rtp , @JohnAudi, thank you very much for helping, it was resolved,

i put the project in the root directory (so it was supposed to work) bit it even didn't,
for example www.xyz.com/manage didn't open (virtual link, no folder called manage exists)
but www.xyz.com/index.php/manage worked.

so i tried looking and i found that i needed to redirect all requests to index.php,
i created an " htaccess " file, but i noticed that it wasn't parsed by the server.

it appeared finally that it's a stupid windows server, and i had to create a "web.config" file that performs URL rewriting.
it worked in the end.

Thank you for taking the time to help.

Offline

#8 April 12 2014

rolf
Member

Re: PHP help needed

ironman wrote:

it appeared finally that it's a stupid windows server, and i had to create a "web.config" file that performs URL rewriting.
it worked in the end.

Thank you for taking the time to help.

You're welcome.

Really, no offense meant, but I'm not sure it's the server that's stupid. htaccess are an apache-only feature. It's like plugging a 220V device in a 110V plug, and saying it's not working because of the stupid electricity company.

Anyway, good job fixing it.

Last edited by rolf (April 12 2014)

Offline

Board footer