简体   繁体   中英

How to enable SQLite Support on CloudFoundry (PHP Buildpack)

I'm building an application on IBM Bluemix using CloudFoundry. I managed to deploy php-buildpack . How can I enable also SQLite Support? ...I'm not even sure if sqlite is included in the buildpack as there is only "pdo_sqlite" listed as an extension.

If I can't get sqlite support out of this buildpack, is there any other way how to have sqlite support?

Although the instructions in Jeff Sloyer's answer is correct, you might want to reconsider using sqlite. SQLite is an in-process database and its contents are backed up on the filesystem. Within Bluemix/Cloud Foundry, the filesystem that you run your application on is ephemeral, meaning that each time you restart your application you will lose anything you saved onto the filesytem, thus you will lose the contents of your database.

You have to enable the library in .bp-config/options.json file. Like the example below

{
    "PHP_EXTENSIONS": ["pdo_sqlite"]
}

PDO is just a wrapper around database access in PHP, for more info check out what is the difference between sqlite3 and pdo_sqlite on StackOverflow.

If you run phpinfo() on your app you will see SQLite3 is installed.

sqlite3的

If you run the following.

if (class_exists('SQLite3')) {
    echo "sqlite3 is here";
}

It will return and say sqlite3 is installed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM