API Platform version(s) affected: 4.0.2
Description
I have an existing, containerized Laravel project. My app container doesn't contain Composer, because I use Composer separately via the official Composer image. I've installed the api-platform/laravel package via the following command:
docker run --rm -v $(pwd):/app composer require api-platform/laravel
It works fine. Then, I've tried to test API Platform so I've added an attribute to my User model:
#[ApiResource(operations: [new Get(), new GetCollection()])]
class User extends AbstractModel implements
AuthenticatableContract,
AuthorizableContract
{
// ...
}
The problem starts when after that, I run the composer install command again:
docker run --rm -v $(pwd):/app composer install
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Illuminate\Database\QueryException
could not find driver (Connection: mariadb, SQL: select column_name as `name`, data_type as `type_name`, column_type as `type`, collation_name as `collation`, is_nullable as `nullable`, column_default as `default`, column_comment as `comment`, generation_expression as `expression`, extra as `extra` from information_schema.columns where table_schema = 'admin_api' and table_name = 'users' order by ordinal_position asc)
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:825
821▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
822▕ );
823▕ }
824▕
➜ 825▕ throw new QueryException(
826▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
827▕ );
828▕ }
829▕ }
1 [internal]:0
Illuminate\Foundation\Application::Illuminate\Foundation\{closure}(Object(ApiPlatform\Laravel\ApiPlatformProvider), "ApiPlatform\Laravel\ApiPlatformProvider")
+46 vendor frames
48 [internal]:0
Illuminate\Foundation\Application::Illuminate\Foundation\{closure}(Object(ApiPlatform\Laravel\ApiPlatformProvider), "ApiPlatform\Laravel\ApiPlatformProvider")
In this case, the package wants to establish a driver and the database connection during installation, but obviously cannot, because there is no such thing in this Composer's container.
Why does it want to connect to the database? How could it be solved so that it doesn't do it? I don't think installing a package would justify the existence of a database connection.
How to reproduce
- clone a laravel project
- add the
api-platform/laravel as dependency
- add an attribute to User model like above
- run the
composer install command in the official Composer container
docker run --rm -v $(pwd):/app composer install
API Platform version(s) affected: 4.0.2
Description
I have an existing, containerized Laravel project. My app container doesn't contain Composer, because I use Composer separately via the official Composer image. I've installed the api-platform/laravel package via the following command:
docker run --rm -v $(pwd):/app composer require api-platform/laravelIt works fine. Then, I've tried to test API Platform so I've added an attribute to my User model:
The problem starts when after that, I run the
composer installcommand again:In this case, the package wants to establish a driver and the database connection during installation, but obviously cannot, because there is no such thing in this Composer's container.
Why does it want to connect to the database? How could it be solved so that it doesn't do it? I don't think installing a package would justify the existence of a database connection.
How to reproduce
api-platform/laravelas dependencycomposer installcommand in the official Composer containerdocker run --rm -v $(pwd):/app composer install