php 64 bit with php_int_max = 2147483647

10,437

Solution 1

If you're running a windows OS, wampServer suggests you are, this is your answer:

On windows x86_64, PHP_INT_MAX is 2147483647. This is because in the underlying c-code, a long is 32 bit.

Note that this doesn't mean that Windows doesn't support 64bit int's: int64_t does exist, but it's not used by PHP AFAIK.
I've managed to come up with this link, on that page, there's some code you might be able to use, to add support for 64bit ints to your code

Solution 2

In the file RequestUtil.php, it does the following check:

if (strlen((string) PHP_INT_MAX) < 19) {
    // Looks like we're running on a 32-bit build of PHP.  This could cause problems because some of the numbers
    // we use (file sizes, quota, etc) can be larger than 32-bit ints can handle.
    throw new \Exception("The Dropbox SDK uses 64-bit integers, but it looks like we're running on a version of PHP that doesn't support 64-bit integers (PHP_INT_MAX=" . ((string) PHP_INT_MAX) . ").  Library: \"" . __FILE__ . "\"");
}

You can comment it out and try hacking your way from there.

If I were you, I'd write my own Dropbox API implementation using strings and not integers.

PS: But this is what I do so I enjoy it :)

Solution 3

Try PHP7 - the current master http://windows.php.net/downloads/snaps/master/ . 64-bit builds now exploit all the capabilities of the 64-bit Windows.

Solution 4

Go to 'vendor/dropbox/dropbox-sdk/lib/Dropbox'
and comment lines 19-23 in RequestUtil.php.

Comment this section:

/*if (strlen((string) PHP_INT_MAX) < 19) {
    // Looks like we're running on a 32-bit build of PHP.  This could cause problems because some of the numbers
    // we use (file sizes, quota, etc) can be larger than 32-bit ints can handle.
    throw new \Exception("The Dropbox SDK uses 64-bit integers, but it looks like we're running on a version of PHP that doesn't support 64-bit integers (PHP_INT_MAX=" . ((string) PHP_INT_MAX) . ").  Library: \"" . __FILE__ . "\"");
}*/

That's it.

Share:
10,437
mikellez
Author by

mikellez

Updated on June 15, 2022

Comments

  • mikellez
    mikellez almost 2 years

    I have install WampServer 2.0 that has apache 2.4.4, mysql 5.6.12, and php 5.4.12. When I echo PHP_INT_MAX it gave me 2147483647. I have also echo phpinfo() and the architecture indicates x64. This suppose to be not happening because my php is 64 bit right? I need my php to support 64 bit integer. I need my PHP_INT_MAX to be 9223372036854775807.

    Can somebody help me? Thanks

  • mikellez
    mikellez over 10 years
    thanks for the reply. So is there any way to solve this problem? I don't really understand what it is telling me to do with the link you gave me.
  • Elias Van Ootegem
    Elias Van Ootegem over 10 years
    @user2615039: there is a hacky workaround, that doesn't require you to switch to linux ;)
  • mikellez
    mikellez over 10 years
    thanks for the alternative solution, just hope it won't cause problems later on.
  • CodeAngry
    CodeAngry over 10 years
    @user2615039 It might, but you can at least move on with testing. Always try to treat long integers as string and you might get away with it.
  • Sędziwój
    Sędziwój over 7 years
    "PHP 7 provides full 64-bit support. The x64 builds of PHP 7 support native 64-bit integers, LFS, memory_limit and much more." So, all builds, not only master: windows.php.net/download
  • Anatol Belski
    Anatol Belski over 7 years
    Yea, 7.0 was master to the time of posting :) After the GA it's now any build OFC.