I have configured my db-connection in my *.env
-file in my Laravel Framework 9.48.0
project, which I would like to try on github codespaces. I want to connect to an externally hosted db server.
When running php artisan migrate
I get:
@githubcoder ➜ /workspaces/ghProject (main ✗) $ php artisan migrate:fresh
Xdebug: [Step Debug] Could not connect to debugging client. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port).
Dropping all tables .................................................................................................................... 11ms FAIL
Illuminate\Database\QueryException
could not find driver (SQL: SHOW FULL TABLES WHERE table_type = 'BASE TABLE')
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:760
756▕ // If an exception occurs when attempting to run a query, we'll format the error
757▕ // message to include the bindings with SQL, which will make this exception a
758▕ // lot more helpful to the developer instead of just the database's errors.
759▕ catch (Exception $e) {
➜ 760▕ throw new QueryException(
761▕ $query, $this->prepareBindings($bindings), $e
762▕ );
763▕ }
764▕ }
44 vendor frames
45 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
Xdebug: [Step Debug] Could not connect to debugging client. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port).
Xdebug: [Step Debug] Could not connect to debugging client. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port).
Xdebug: [Step Debug] Could not connect to debugging client. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port).
I tried to enable ;extension=pdo_mysql.so
however in my php.ini
file this option does not exist:
phpinfo()
PHP Version => 8.1.4
System => Linux codespaces-58b9f9 5.4.0-1100-azure #106~18.04.1-Ubuntu SMP Mon Dec 12 21:49:35 UTC 2022 x86_64
Build Date => Dec 19 2022 20:29:04
Build System => Linux buildkitsandbox 5.15.0-1024-azure #30-Ubuntu SMP Wed Nov 16 23:37:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Configure Command => './configure' '--prefix=/usr/local/php/8.1.4' '--with-config-file-path=/usr/local/php/8.1.4/ini' '--with-config-file-scan-dir=/usr/local/php/8.1.4/ini/conf.d' '--enable-option-checking=fatal' '--with-curl' '--with-libedit' '--with-openssl' '--with-zlib' '--with-password-argon2' '--with-sodium=shared' '--with-pear' 'EXTENSION_DIR=/usr/local/php/8.1.4/extensions'
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /usr/local/php/8.1.4/ini
Loaded Configuration File => /usr/local/php/8.1.4/ini/php.ini
Scan this dir for additional .ini files => /usr/local/php/8.1.4/ini/conf.d
Additional .ini files parsed => /usr/local/php/8.1.4/ini/conf.d/xdebug.ini
PHP API => 20210902
PHP Extension => 20210902
Zend Extension => 420210902
Zend Extension Build => API420210902,NTS
PHP Extension Build => API20210902,NTS
Debug Build => no
Thread Safety => disabled
Zend Signal Handling => enabled
Zend Memory Manager => enabled
Zend Multibyte Support => disabled
IPv6 Support => enabled
DTrace Support => disabled
Registered PHP Streams => https, ftps, compress.zlib, php, file, glob, data, http, ftp, phar
Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, tls, tlsv1.0, tlsv1.1, tlsv1.2, tlsv1.3
Registered Stream Filters => zlib.*, convert.iconv.*, string.rot13, string.toupper, string.tolower, convert.*, consumed, dechunk
This program makes use of the Zend Scripting Language Engine:
Zend Engine v4.1.4, Copyright (c) Zend Technologies
with Xdebug v3.2.0, Copyright (c) 2002-2022, by Derick Rethans
_______________________________________________________________________
Configuration
Core
PHP Version => 8.1.4
Directive => Local Value => Master Value
allow_url_fopen => On => On
allow_url_include => Off => Off
arg_separator.input => & => &
arg_separator.output => & => &
auto_append_file => no value => no value
auto_globals_jit => On => On
auto_prepend_file => no value => no value
browscap => no value => no value
default_charset => UTF-8 => UTF-8
default_mimetype => text/html => text/html
disable_classes => no value => no value
disable_functions => no value => no value
display_errors => Off => Off
display_startup_errors => Off => Off
doc_root => no value => no value
docref_ext => no value => no value
docref_root => no value => no value
enable_dl => Off => Off
enable_post_data_reading => On => On
error_append_string => no value => no value
error_log => no value => no value
error_prepend_string => no value => no value
error_reporting => 22527 => 22527
expose_php => On => On
extension_dir => /usr/local/php/8.1.4/extensions => /usr/local/php/8.1.4/extensions
fiber.stack_size => no value => no value
file_uploads => On => On
hard_timeout => 2 => 2
highlight.comment => <font style="color: #FF8000">#FF8000</font> => <font style="color: #FF8000">#FF8000</font>
highlight.default => <font style="color: #0000BB">#0000BB</font> => <font style="color: #0000BB">#0000BB</font>
highlight.html => <font style="color: #000000">#000000</font> => <font style="color: #000000">#000000</font>
highlight.keyword => <font style="color: #007700">#007700</font> => <font style="color: #007700">#007700</font>
highlight.string => <font style="color: #DD0000">#DD0000</font> => <font style="color: #DD0000">#DD0000</font>
html_errors => Off => Off
ignore_repeated_errors => Off => Off
ignore_repeated_source => Off => Off
ignore_user_abort => Off => Off
implicit_flush => On => On
include_path => .:/usr/local/php/8.1.4/lib/php => .:/usr/local/php/8.1.4/lib/php
input_encoding => no value => no value
internal_encoding => no value => no value
log_errors => On => On
mail.add_x_header => Off => Off
mail.force_extra_parameters => no value => no value
mail.log => no value => no value
max_execution_time => 0 => 0
max_file_uploads => 20 => 20
max_input_nesting_level => 64 => 64
max_input_time => -1 => -1
max_input_vars => 1000 => 1000
memory_limit => 128M => 128M
open_basedir => no value => no value
output_buffering => 0 => 0
output_encoding => no value => no value
output_handler => no value => no value
post_max_size => 8M => 8M
precision => 14 => 14
realpath_cache_size => 4096K => 4096K
realpath_cache_ttl => 120 => 120
register_argc_argv => On => On
report_memleaks => On => On
report_zend_debug => Off => Off
request_order => GP => GP
sendmail_from => no value => no value
sendmail_path => /usr/sbin/sendmail -t -i => /usr/sbin/sendmail -t -i
serialize_precision => -1 => -1
short_open_tag => Off => Off
SMTP => localhost => localhost
smtp_port => 25 => 25
sys_temp_dir => no value => no value
syslog.facility => LOG_USER => LOG_USER
syslog.filter => no-ctrl => no-ctrl
syslog.ident => php => php
unserialize_callback_func => no value => no value
upload_max_filesize => 2M => 2M
upload_tmp_dir => no value => no value
user_dir => no value => no value
user_ini.cache_ttl => 300 => 300
user_ini.filename => .user.ini => .user.ini
variables_order => GPCS => GPCS
xmlrpc_error_number => 0 => 0
xmlrpc_errors => Off => Off
zend.assertions => -1 => -1
zend.detect_unicode => On => On
zend.enable_gc => On => On
zend.exception_ignore_args => On => On
zend.exception_string_param_max_len => 0 => 0
zend.multibyte => Off => Off
zend.script_encoding => no value => no value
zend.signal_check => Off => Off
ctype
ctype functions => enabled
curl
cURL support => enabled
cURL Information => 7.68.0
Age => 5
Features
AsynchDNS => Yes
CharConv => No
Debug => No
GSS-Negotiate => No
IDN => Yes
IPv6 => Yes
krb4 => No
Largefile => Yes
libz => Yes
NTLM => Yes
NTLMWB => Yes
SPNEGO => Yes
SSL => Yes
SSPI => No
TLS-SRP => Yes
HTTP2 => Yes
GSSAPI => Yes
KERBEROS5 => Yes
UNIX_SOCKETS => Yes
PSL => Yes
HTTPS_PROXY => Yes
MULTI_SSL => No
BROTLI => Yes
Protocols => dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtmp, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp
Host => x86_64-pc-linux-gnu
SSL Version => OpenSSL/1.1.1f
ZLib Version => 1.2.11
libSSH Version => libssh/0.9.3/openssl/zlib
Directive => Local Value => Master Value
curl.cainfo => no value => no value
date
date/time support => enabled
timelib version => 2021.11
"Olson" Timezone Database Version => 2021.5
Timezone Database => internal
Default timezone => UTC
Directive => Local Value => Master Value
date.default_latitude => 31.7667 => 31.7667
date.default_longitude => 35.2333 => 35.2333
date.sunrise_zenith => 90.833333 => 90.833333
date.sunset_zenith => 90.833333 => 90.833333
date.timezone => no value => no value
dom
DOM/XML => enabled
DOM/XML API Version => 20031129
libxml Version => 2.9.10
HTML Support => enabled
XPath Support => enabled
XPointer Support => enabled
Schema Support => enabled
RelaxNG Support => enabled
fileinfo
fileinfo support => enabled
libmagic => 540
filter
Input Validation and Filtering => enabled
Directive => Local Value => Master Value
filter.default => unsafe_raw => unsafe_raw
filter.default_flags => no value => no value
hash
hash support => enabled
Hashing Engines => md2 md4 md5 sha1 sha224 sha256 sha384 sha512/224 sha512/256 sha512 sha3-224 sha3-256 sha3-384 sha3-512 ripemd128 ripemd160 ripemd256 ripemd320 whirlpool tiger128,3 tiger160,3 tiger192,3 tiger128,4 tiger160,4 tiger192,4 snefru snefru256 gost gost-crypto adler32 crc32 crc32b crc32c fnv132 fnv1a32 fnv164 fnv1a64 joaat murmur3a murmur3c murmur3f xxh32 xxh64 xxh3 xxh128 haval128,3 haval160,3 haval192,3 haval224,3 haval256,3 haval128,4 haval160,4 haval192,4 haval224,4 haval256,4 haval128,5 haval160,5 haval192,5 haval224,5 haval256,5
iconv
iconv support => enabled
iconv implementation => glibc
iconv library version => 2.31
...
Any suggestions how to connect from codespaces to an externaly hosted db?
I appreciate your replies
CodePudding user response:
I fixed this issue using Devcontainers
. Here is my config:
// See https://aka.ms/vscode-remote/devcontainer.json for format details.
{
"name": "codespaces-laravel",
"dockerComposeFile": ["docker-compose.yml"],
"workspaceFolder": "/workspace",
"service": "app",
"shutdownAction": "stopCompose",
"extensions": [
"editorconfig.editorconfig",
"ryannaddy.laravel-artisan",
"amiralizadeh9480.laravel-extra-intellisense",
"stef-k.laravel-goto-controller",
"codingyu.laravel-goto-view",
"mikestead.dotenv",
"eg2.tslint",
"christian-kohler.path-intellisense",
"esbenp.prettier-vscode",
"CoenraadS.bracket-pair-colorizer"
],
"settings": {
"#terminal.integrated.shell.linux": "/bin/bash"
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [80],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "cp .env.example .env && composer install && php artisan key:generate && yarn install && yarn run development",
"portsAttributes": {
"80": {
"label": "HTTP"
}
}
}