admin管理员组文章数量:1296914
I am using a lightly modified version of the API Platform Symfony environment. Since part of the postgres system built into that environment is not working for me right now, I'm falling back to using sqlite as the database provider.
I somewhat predictably get An exception occurred in the driver: could not find driver
when loading any of my Symfony app's database-connected pages in the browser. That makes sense, since the docker compose setup is not by default configured to use sqlite.
What's surprising to me is how difficult it is to actually get the driver installed on the machine in question. Based on info seen in some other questions/answers, here's what I've tried adding to the Dockerfile, without success:
RUN apt update && apt upgrade -y
RUN apt-get install -y ca-certificates apt-transport-https
RUN apt-get install -y software-properties-common
RUN apt-get install -y python3-launchpadlib
RUN add-apt-repository noble-updates/main
RUN add-apt-repository ppa:ondrej/php
RUN apt update
RUN apt upgrade
RUN apt install -y php7.3-sqlite3
RUN rm -rf /var/lib/apt/lists/*
Unfortunately, this yields the following output when doing a docker compose build --no-cache
:
=> ERROR [php frankenphp_base 9/17] RUN apt update 0.8s
------
> [php frankenphp_base 9/17] RUN apt update:
0.150
0.150 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
0.150
0.223 Hit:1 bookworm InRelease
0.225 Hit:2 bookworm-updates InRelease
0.239 Hit:3 bookworm-security InRelease
0.345 Ign:4 bookworm InRelease
0.372 Err:5 bookworm Release
0.372 404 Not Found [IP: 185.125.190.80 443]
0.452 Reading package lists...
0.763 E: The repository ' bookworm Release' does not have a Release file.
------
failed to solve: process "/bin/sh -c apt update" did not complete successfully: exit code: 100
Anybody know a sneaky way of getting this elusive package (or a functional equivalent) installed?
===
EDIT: I realized somewhat belatedly that I was barking up the wrong tree. My app was being served via symfony serve
on my host system, not within the docker container. As soon as I realized that, I verified that the php-sqlite3
apt package had already been installed. After that, it was a simple matter of un-commentating the line in my php.ini
file that said ;extension=pdo_sqlite
and after a restart of my symfony serve
command ... presto! Everything worked!
I am using a lightly modified version of the API Platform Symfony environment. Since part of the postgres system built into that environment is not working for me right now, I'm falling back to using sqlite as the database provider.
I somewhat predictably get An exception occurred in the driver: could not find driver
when loading any of my Symfony app's database-connected pages in the browser. That makes sense, since the docker compose setup is not by default configured to use sqlite.
What's surprising to me is how difficult it is to actually get the driver installed on the machine in question. Based on info seen in some other questions/answers, here's what I've tried adding to the Dockerfile, without success:
RUN apt update && apt upgrade -y
RUN apt-get install -y ca-certificates apt-transport-https
RUN apt-get install -y software-properties-common
RUN apt-get install -y python3-launchpadlib
RUN add-apt-repository http://archive.ubuntu/ubuntu noble-updates/main
RUN add-apt-repository ppa:ondrej/php
RUN apt update
RUN apt upgrade
RUN apt install -y php7.3-sqlite3
RUN rm -rf /var/lib/apt/lists/*
Unfortunately, this yields the following output when doing a docker compose build --no-cache
:
=> ERROR [php frankenphp_base 9/17] RUN apt update 0.8s
------
> [php frankenphp_base 9/17] RUN apt update:
0.150
0.150 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
0.150
0.223 Hit:1 http://deb.debian./debian bookworm InRelease
0.225 Hit:2 http://deb.debian./debian bookworm-updates InRelease
0.239 Hit:3 http://deb.debian./debian-security bookworm-security InRelease
0.345 Ign:4 https://ppa.launchpadcontent/ondrej/php/ubuntu bookworm InRelease
0.372 Err:5 https://ppa.launchpadcontent/ondrej/php/ubuntu bookworm Release
0.372 404 Not Found [IP: 185.125.190.80 443]
0.452 Reading package lists...
0.763 E: The repository 'https://ppa.launchpadcontent/ondrej/php/ubuntu bookworm Release' does not have a Release file.
------
failed to solve: process "/bin/sh -c apt update" did not complete successfully: exit code: 100
Anybody know a sneaky way of getting this elusive package (or a functional equivalent) installed?
===
EDIT: I realized somewhat belatedly that I was barking up the wrong tree. My app was being served via symfony serve
on my host system, not within the docker container. As soon as I realized that, I verified that the php-sqlite3
apt package had already been installed. After that, it was a simple matter of un-commentating the line in my php.ini
file that said ;extension=pdo_sqlite
and after a restart of my symfony serve
command ... presto! Everything worked!
1 Answer
Reset to default 1For a PHP extension (module) to be available, it must
- a) be installed (so the binary library is there,
.so
on Linux) and - b) the extension must be loaded (so the binary library is running with php).
Installing the binary:
install-php-extensions pdo_sqlite
Activating the binary (official PHP docker images):
docker-php-ext-enable pdo_sqlite
This is equivalent to using the systems package manager and telling PHP to load the ini-configuration with an extension=<ext-name> directive.
Some extensions that are Zend extensions need the zend_extension directive instead.
For PECL extensions, the pecl utility becomes the "package manager".
Now in your question you're making use of multiple things to install the extension and that is probably part of the confusion:
- The systems package manager (apt-get)
- Extending it with private repositories (ppa:ondrej/php)
- The FrankenPHP PHP extension install script (install-php-extensions, via docker-php-extension-installer)
In case this is some kind of shotgun debugging, the install-php-extensions script should suffice. According to FrankenPHP #845 they build on-top the official PHP images and use docker-php-extension-installer which is also designed for official setups.
I'd isolate the case and use that script only without running the package managers etc. as it is originally outlined in the FrankenPHP documentation and see if it works.
If there are additional requirements via the package manager, I'd keep that separated and only when all things work in isolation, bring them more close together (if at all).
References
- PHP: Description of core php.ini directives - Manual (php)
- php - Official Image | Docker Hub (docker)
- How to Install More PHP Extensions | Building Custom Docker Image | FrankenPHP: the modern PHP app server (frankenphp.dev)
本文标签: API Platform with sqlite Could not find driverStack Overflow
版权声明:本文标题:API Platform with sqlite: Could not find driver - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741632463a2389445.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
install-php-extensions pdo_sqlite
in my list of commands that get run, but I still get thecould not find driver
message. So I believe there's still a dependency on another layer that's not being satisfied ;-) – Mayor of the Plattenbaus Commented Feb 12 at 7:47install-php-extensions pdo_sqlite
command you're commenting about, but nevertheless, then probably the reason might be that the documentation there falls short because it hides the step to enable (activate) the module after installing. IIRC thedocker-php-ext-enable <ext-name>
should be called (via), please check. – hakre Commented Feb 12 at 8:45php7.3-sqlite3
hints its not supported OOTB, so you may need to enable the extension of wish with both the PHP CLI and all the others SAPIs you want to make use of it. How are you testing it is enabled? Which SAPIs are you testing against? – hakre Commented Feb 12 at 9:14