Search code examples
phpovh

Differences between local and remote servers


I am developing a website with Lumen framework.

Everything is configured and works perfectly locally. However, this is not the case on the remote server.

Examples:

  • When I recover a data from my database, even if the column contains only integers, the result in local is integer, but in remote : string. I have to specify (int) before the integer values to be sure they are integer.

  • Locally, all my classes belong to namespaces. Everything works locally and in remote, sometimes I find myself with Class 'blabla\blibli' not found

Locally, I use Xampp (PHP Version 5.6.14, MySQL version 5.0.11-dev) and remove, I am on a shared server OVH (PHP Version 5.6.15, MySQL version 5.1.73).

Have you ever been confronted with that? Is there a way to fix this? May be a configuration file to write?

EDIT : Given the comments below, it seems that the answers to my questions actually depends on the operating system use.

Locally, I am working on a Windows machine, while in remote, it is a machine running Linux. Windows seems less of a hassle with certain rules, such as case sensitive.


Solution

  • When I recover a data from my database, even if the column contains only integers, the result in local is integer, but in remote : string. I have to specify (int) before the integer values to be sure they are integer.

    This happens because PHP doesn't know how to interpret the query result. There is no information on how to interpret column values. To fix that and to have correct type representation in PHP, you must have MySQL Native Driver installed (mysqlnd).

    Here's a link to documentation page that explains how to do it.

    Locally, all my classes belong to namespaces. Everything works locally and in remote, sometimes I find myself with Class 'blabla\blibli' not found

    As per comments, it appears you're developing on one OS and deploying on another OS. Since Windows are actually MUCH MUCH WORSE than Linux (and this isn't me being a fan of Linux, it's a simple fact), they tend to forgive a lot when it comes to case sensitivity and what not.

    Windows being forgiving for such things doesn't mean they're better or that there's less hassle with Windows (from a sys admin POV, Windows are a nightmare). It just means that you can't be lazy and expect OS to forgive everything and guess how you intended your code to work.

    • Be consistent
    • Set your development environment to match your deployment environment. You can use virtual machines for that. If you prefer developing under Windows, you can use Oracle Virtualbox to run a Linux OS, set up Samba and in Windows you can map a Linux drive. That lets you run your IDE under Windows, and all the code is saved to Linux box. Your web server and php should run under Linux and you can access it via your browser that runs under Windows
    • Set up tests. Run them before you deploy. That will tell you whether you might have missed or omitted something
    • Be consistent

    Good luck.