Closed ajitirto closed 1 year ago
What is the output of composer show
?
Hi,
I have this error after install the package and execute php artisan ide-helper:generate
from the laravel-ide-helper package from barryvdh in a Laravel 8.x installation.
PS D:\Proyectos\php\salud-back> php artisan ide-helper:generate
Error
Class "bfinlay\SpreadsheetSeeder\Tests\Workaround\RefreshDatabase\RefreshDatabaseMySqlConnection" not found
at D:\Proyectos\php\salud-back\vendor\bfinlay\laravel-excel-seeder\src\SpreadsheetSeederServiceProvider.php:101
97▕ ];
98▕
99▕ foreach($connections as $driver => $class) {
100▕ Connection::resolverFor($driver, function($pdo, $database = '', $tablePrefix = '', array $config = []) use ($driver, $class) {
➜ 101▕ $connection = new $class['connection']($pdo, $database, $tablePrefix, $config);
102▕ $connection->setSchemaGrammar(new $class['schemaGrammar']);
103▕
104▕ return $connection;
105▕ });
1 D:\Proyectos\php\salud-back\vendor\laravel\framework\src\Illuminate\Database\Connectors\ConnectionFactory.php:273
bfinlay\SpreadsheetSeeder\SpreadsheetSeederServiceProvider::bfinlay\SpreadsheetSeeder\{closure}(Object(Closure), "salud-back", "")
2 D:\Proyectos\php\salud-back\vendor\laravel\framework\src\Illuminate\Database\Connectors\ConnectionFactory.php:76
Illuminate\Database\Connectors\ConnectionFactory::createConnection("mysql", Object(Closure), "salud-back", "")
This is my composer:show
output:
aacotroneo/laravel-saml2 2.1.0 A Laravel package for Saml2 integration as a SP (service provider) for multiple IdPs, based on OneLogin toolkit which is much more lightweight than simplesamlphp.
asm89/stack-cors v2.1.1 Cross-origin resource sharing library and stack middleware
barryvdh/laravel-debugbar v3.6.7 PHP Debugbar integration for Laravel
barryvdh/laravel-dompdf v1.0.2 A DOMPDF Wrapper for Laravel
barryvdh/laravel-ide-helper v2.11.0 Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.
barryvdh/reflection-docblock v2.0.6
beyondcode/laravel-query-detector 1.6.0 Laravel N+1 Query Detector
bfinlay/laravel-excel-seeder v3.3.3 Seed the database with Laravel using Excel, XLSX, XLS, CSV, ODS, Gnumeric, XML, HTML, SLK files
brick/math 0.9.3 Arbitrary-precision arithmetic library
composer/ca-bundle 1.3.1 Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla CA bundle.
composer/composer 2.2.4 Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.
composer/metadata-minifier 1.0.0 Small utility library that handles metadata minification and expansion.
composer/pcre 1.0.0 PCRE wrapping library that offers type-safe preg_* replacements.
composer/semver 3.2.7 Semver library that offers utilities, version constraint parsing and validation.
composer/spdx-licenses 1.5.6 SPDX licenses list and validation library.
composer/xdebug-handler 2.0.4 Restarts a process without Xdebug.
dflydev/dot-access-data v3.0.1 Given a deep data structure, access data by dot notation.
directorytree/ldaprecord v2.9.1 A fully-featured LDAP ORM.
directorytree/ldaprecord-laravel v2.5.2 LDAP Authentication & Management for Laravel.
doctrine/cache 2.1.1 PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others.
doctrine/dbal 3.3.0 Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.
doctrine/deprecations v0.5.3 A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.
doctrine/event-manager 1.1.1 The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.
doctrine/inflector 2.0.4 PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.
doctrine/instantiator 1.4.0 A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer 1.2.2 PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.
dompdf/dompdf v1.2.2 DOMPDF is a CSS 2.1 compliant HTML to PDF converter
dragonmantank/cron-expression v3.3.1 CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due
egulias/email-validator 2.1.25 A library for validating emails against several RFCs
ezyang/htmlpurifier v4.14.0 Standards compliant HTML filter written in PHP
facade/flare-client-php 1.9.1 Send PHP errors to Flare
facade/ignition 2.17.4 A beautiful error page for Laravel applications.
facade/ignition-contracts 1.0.2 Solution contracts for Ignition
fakerphp/faker v1.17.0 Faker is a PHP library that generates fake data for you.
fideloper/proxy 4.4.1 Set trusted proxies for Laravel
filp/whoops 2.14.5 php error handling for cool kids
flynsarmy/csv-seeder v2.0.6 Allows seeding of the database with CSV files
fruitcake/laravel-cors v2.0.5 Adds CORS (Cross-Origin Resource Sharing) headers support in your Laravel application
graham-campbell/result-type v1.0.4 An Implementation Of The Result Type
guzzlehttp/guzzle 7.4.1 Guzzle is a PHP HTTP client library
guzzlehttp/promises 1.5.1 Guzzle promises library
guzzlehttp/psr7 2.1.0 PSR-7 message implementation that also provides common utility methods
hamcrest/hamcrest-php v2.0.1 This is the PHP port of Hamcrest Matchers
justinrainbow/json-schema 5.2.11 A library to validate a json schema.
laravel-json-api/core v1.1.0 Contracts and support classes for Laravel JSON:API packages.
laravel-json-api/eloquent v1.0.1 Serialize Eloquent models as JSON:API resources.
laravel-json-api/encoder-neomerx v1.1.0 Encode JSON:API resources using the neomerx/json-api package.
laravel-json-api/exceptions v1.0.0 JSON:API exception parsing for Laravel applications.
laravel-json-api/laravel v1.1.0 JSON:API for Laravel applications.
laravel-json-api/neomerx-json-api v4.0.2 Framework agnostic JSON API (jsonapi.org) implementation
laravel-json-api/spec v1.0.0 Validate JSON documents for compliance with the JSON:API specification.
laravel-json-api/validation v1.0.0 Laravel validation for JSON:API resources.
laravel/framework v8.80.0 The Laravel Framework.
laravel/sail v1.13.0 Docker files for running a basic Laravel application.
laravel/serializable-closure v1.0.5 Laravel Serializable Closure provides an easy and secure way to serialize closures in PHP.
laravel/tinker v2.7.0 Powerful REPL for the Laravel framework.
laravel/ui v3.4.2 Laravel UI utilities and presets.
league/commonmark 2.1.1 Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and GitHub-Flavored Markdown (GFM)
league/config v1.1.1 Define configuration arrays with strict schemas and access values with dot notation
league/flysystem 1.1.9 Filesystem abstraction: Many filesystems, one API.
league/mime-type-detection 1.9.0 Mime-type detection for Flysystem
maatwebsite/excel 3.1.40 Supercharged Excel exports and imports in Laravel
maennchen/zipstream-php 2.2.1 ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.
markbaker/complex 3.0.1 PHP Class for working with complex numbers
markbaker/matrix 3.0.0 PHP Class for working with matrices
maximebf/debugbar v1.18.0 Debug bar in the browser for php application
mockery/mockery 1.4.4 Mockery is a simple yet flexible PHP mock object framework
monolog/monolog 2.3.5 Sends your logs to files, sockets, inboxes, databases and various web services
myclabs/deep-copy 1.10.2 Create deep copies (clones) of your objects
myclabs/php-enum 1.8.4 PHP Enum implementation
nesbot/carbon 2.55.2 An API extension for DateTime that supports 281 different languages.
nette/schema v1.2.2 📐 Nette Schema: validating data structures against a given Schema.
nette/utils v3.2.6 🛠 Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password gener...
nikic/php-parser v4.13.2 A PHP parser written in PHP
nunomaduro/collision v5.11.0 Cli error handling for console/command-line PHP applications.
onelogin/php-saml 3.6.1 OneLogin PHP SAML Toolkit
opis/closure 3.6.2 A library that can be used to serialize closures (anonymous functions) and arbitrary objects.
phar-io/manifest 2.0.3 Component for reading phar.io manifest information from a PHP Archive (PHAR)
phar-io/version 3.1.0 Library for handling version information and constraints
phenx/php-font-lib 0.5.4 A library to read, parse, export and make subsets of different types of font files.
phenx/php-svg-lib 0.4.1 A library to read, parse and export to PDF SVG files.
phpdocumentor/reflection-common 2.2.0 Common reflection classes used by phpdocumentor to reflect the code structure
phpdocumentor/reflection-docblock 5.3.0 With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.
phpdocumentor/type-resolver 1.6.0 A PSR-5 based resolver of Class names, Types and Structural Element Names
phpoffice/phpspreadsheet 1.24.1 PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine
phpoption/phpoption 1.8.1 Option Type for PHP
phpspec/prophecy v1.15.0 Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage 9.2.10 Library that provides collection, processing, and rendering functionality for PHP code coverage information.
phpunit/php-file-iterator 3.0.6 FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-invoker 3.1.1 Invoke callables with a timeout
phpunit/php-text-template 2.0.4 Simple template engine.
phpunit/php-timer 5.0.3 Utility class for timing
phpunit/phpunit 9.5.11 The PHP Unit Testing framework.
psr/cache 3.0.0 Common interface for caching libraries
psr/container 1.1.2 Common Container Interface (PHP FIG PSR-11)
psr/event-dispatcher 1.0.0 Standard interfaces for event handling.
psr/http-client 1.0.1 Common interface for HTTP clients
psr/http-factory 1.0.1 Common interfaces for PSR-7 HTTP message factories
psr/http-message 1.0.1 Common interface for HTTP messages
psr/log 2.0.0 Common interface for logging libraries
psr/simple-cache 1.0.1 Common interfaces for simple caching
psy/psysh v0.11.1 An interactive shell for modern PHP.
ralouphie/getallheaders 3.0.3 A polyfill for getallheaders.
ramsey/collection 1.2.2 A PHP library for representing and manipulating collections.
ramsey/uuid 4.2.3 A PHP library for generating and working with universally unique identifiers (UUIDs).
react/promise v2.8.0 A lightweight implementation of CommonJS Promises/A for PHP
robrichards/xmlseclibs 3.1.1 A PHP library for XML Security
sabberworm/php-css-parser 8.4.0 Parser for CSS Files written in PHP
sebastian/cli-parser 1.0.1 Library for parsing CLI options
sebastian/code-unit 1.0.8 Collection of value objects that represent the PHP code units
sebastian/code-unit-reverse-lookup 2.0.3 Looks up which function or method a line of code belongs to
sebastian/comparator 4.0.6 Provides the functionality to compare PHP values for equality
sebastian/complexity 2.0.2 Library for calculating the complexity of PHP code units
sebastian/diff 4.0.4 Diff implementation
sebastian/environment 5.1.3 Provides functionality to handle HHVM/PHP environments
sebastian/exporter 4.0.4 Provides the functionality to export PHP variables for visualization
sebastian/global-state 5.0.3 Snapshotting of global state
sebastian/lines-of-code 1.0.3 Library for counting the lines of code in PHP source code
sebastian/object-enumerator 4.0.4 Traverses array structures and object graphs to enumerate all referenced objects
sebastian/object-reflector 2.0.4 Allows reflection of object attributes, including inherited and non-public ones
sebastian/recursion-context 4.0.4 Provides functionality to recursively process PHP variables
sebastian/resource-operations 3.0.3 Provides a list of PHP built-in functions that operate on resources
sebastian/type 2.3.4 Collection of value objects that represent the types of the PHP type system
sebastian/version 3.0.2 Library that helps with managing the version number of Git-hosted PHP projects
seld/jsonlint 1.8.3 JSON Linter
seld/phar-utils 1.2.0 PHAR file format utilities, for when PHP phars you up
spatie/laravel-permission 5.5.5 Permission handling for Laravel 6.0 and up
swiftmailer/swiftmailer v6.3.0 Swiftmailer, free feature-rich PHP mailer
symfony/console v5.4.2 Eases the creation of beautiful and testable command line interfaces
symfony/css-selector v6.0.2 Converts CSS selectors to XPath expressions
symfony/debug v4.4.37 Provides tools to ease debugging PHP code
symfony/deprecation-contracts v3.0.0 A generic function and convention to trigger deprecation notices
symfony/error-handler v5.4.2 Provides tools to manage errors and ease debugging PHP code
symfony/event-dispatcher v6.0.2 Provides tools that allow your application components to communicate with each other by dispatching events and listening to them
symfony/event-dispatcher-contracts v3.0.0 Generic abstractions related to dispatching event
symfony/filesystem v6.0.0 Provides basic utilities for the filesystem
symfony/finder v5.4.2 Finds files and directories via an intuitive fluent interface
symfony/http-foundation v5.4.2 Defines an object-oriented layer for the HTTP specification
symfony/http-kernel v5.4.2 Provides a structured process for converting a Request into a Response
symfony/mime v5.4.2 Allows manipulating MIME messages
symfony/polyfill-ctype v1.24.0 Symfony polyfill for ctype functions
symfony/polyfill-iconv v1.24.0 Symfony polyfill for the Iconv extension
symfony/polyfill-intl-grapheme v1.24.0 Symfony polyfill for intl's grapheme_* functions
symfony/polyfill-intl-idn v1.24.0 Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-intl-normalizer v1.24.0 Symfony polyfill for intl's Normalizer class and related functions
symfony/polyfill-mbstring v1.24.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php72 v1.24.0 Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/polyfill-php73 v1.24.0 Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/polyfill-php80 v1.24.0 Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
symfony/polyfill-php81 v1.24.0 Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions
symfony/process v5.4.2 Executes commands in sub-processes
symfony/routing v5.4.0 Maps an HTTP request to a set of configuration variables
symfony/service-contracts v2.4.1 Generic abstractions related to writing services
symfony/string v6.0.2 Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way
symfony/translation v6.0.2 Provides tools to internationalize your application
symfony/translation-contracts v3.0.0 Generic abstractions related to translation
symfony/var-dumper v5.4.2 Provides mechanisms for walking through any arbitrary PHP variable
theseer/tokenizer 1.2.1 A small library for converting tokenized PHP source code into XML and potentially other formats
tightenco/collect v8.80.0 Collect - Illuminate Collections as a separate package.
tijsverkoyen/css-to-inline-styles 2.2.4 CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails.
vlucas/phpdotenv v5.4.1 Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.
voku/portable-ascii 1.5.6 Portable ASCII library - performance optimized (ascii) string functions for php.
webmozart/assert 1.10.0 Assertions to validate method input/output with nice error messages.
Thank you.
We use php artisan ide-helper:generate
also. I just confirmed it using barryvdh/laravel-ide-helper
v2.13.0 and bfinlay/laravel-excel-seeder
v3.3.3 and we do not get the issue.
This was just a quick confirmation. I will look into it more later tonight and see if I have any further ideas.
One thing you could try if you haven't already is to delete the vendor folder and rerun composer update
to be sure that all files are in place.
Another thing you can try is to remove the files in bootstrap/cache. In particular services.php in case classes are inappropriately cached. then run composer update
and optionally php artisan config:cache
.
It´s not a barryvdh/laravel-ide-helper problem.
I create a fresh new laravel 8.x project to test and fails too. The steps:
composer create-project laravel/laravel:^8.0 laravel_excel_seeder
Install the package: composer require bfinlay/laravel-excel-seeder
. Here, composer install the ^1.2
version like https://github.com/bfinlay/laravel-excel-seeder/issues/20 . If I force the install with the version with the command composer require bfinlay/laravel-excel-seeder:^3.0
fails with the following output:
./composer.json has been updated
Running composer update bfinlay/laravel-excel-seeder
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- bfinlay/laravel-excel-seeder[v3.0.0, ..., v3.3.3] require phpoffice/phpspreadsheet ~1.7 -> satisfiable by phpoffice/phpspreadsheet[1.7.0, ..., 1.29.0].
- phpoffice/phpspreadsheet[1.15.0, ..., 1.28.0] require maennchen/zipstream-php ^2.1 -> satisfiable by maennchen/zipstream-php[2.1.0, ..., v2.x-dev].
- phpoffice/phpspreadsheet 1.29.0 requires maennchen/zipstream-php ^2.1 || ^3.0 -> satisfiable by maennchen/zipstream-php[2.1.0, ..., v2.x-dev, 3.0.0-beta.1, ..., 3.1.0].
- maennchen/zipstream-php[2.1.0, ..., v2.x-dev] require psr/http-message ^1.0 -> found psr/http-message[1.0, 1.0.1, 1.1] but the package is fixed to 2.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
- maennchen/zipstream-php[3.0.0-beta.1, ..., 3.1.0] require php-64bit ^8.1 -> your php-64bit version (8.0.17) does not satisfy that requirement.
- phpoffice/phpspreadsheet[1.7.0, ..., 1.8.2] require php ^5.6|^7.0 -> your php version (8.0.17) does not satisfy that requirement.
- phpoffice/phpspreadsheet[1.9.0, ..., 1.12.0] require php ^7.1 -> your php version (8.0.17) does not satisfy that requirement.
- phpoffice/phpspreadsheet[1.13.0, ..., 1.14.1] require php ^7.2 -> your php version (8.0.17) does not satisfy that requirement.
- Root composer.json requires bfinlay/laravel-excel-seeder ^3.0 -> satisfiable by bfinlay/laravel-excel-seeder[v3.0.0, ..., v3.3.3].
Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
3. Next, using `composer require bfinlay/laravel-excel-seeder:^3.0 -W` update the dependencies and the install is correct:
```log
./composer.json has been updated
Running composer update bfinlay/laravel-excel-seeder --with-all-dependencies
Loading composer repositories with package information
Updating dependencies
Lock file operations: 12 installs, 2 updates, 0 removals
- Upgrading bfinlay/laravel-excel-seeder (v1.2.2 => v3.3.3)
- Locking composer/semver (3.4.0)
- Locking doctrine/cache (2.2.0)
- Locking doctrine/dbal (3.7.2)
- Locking doctrine/deprecations (1.1.2)
- Locking doctrine/event-manager (1.2.0)
- Locking ezyang/htmlpurifier (v4.17.0)
- Locking maennchen/zipstream-php (2.4.0)
- Locking markbaker/complex (3.0.2)
- Locking markbaker/matrix (3.0.1)
- Locking myclabs/php-enum (1.8.4)
- Locking phpoffice/phpspreadsheet (1.29.0)
- Locking psr/cache (3.0.0)
- Downgrading psr/http-message (2.0 => 1.1)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 12 installs, 2 updates, 0 removals
- Downgrading psr/http-message (2.0 => 1.1): Extracting archive
- Installing markbaker/matrix (3.0.1): Extracting archive
- Installing markbaker/complex (3.0.2): Extracting archive
- Installing myclabs/php-enum (1.8.4): Extracting archive
- Installing maennchen/zipstream-php (2.4.0): Extracting archive
- Installing ezyang/htmlpurifier (v4.17.0): Extracting archive
- Installing phpoffice/phpspreadsheet (1.29.0): Extracting archive
- Installing psr/cache (3.0.0): Extracting archive
- Installing doctrine/deprecations (1.1.2): Extracting archive
- Installing doctrine/event-manager (1.2.0): Extracting archive
- Installing doctrine/cache (2.2.0): Extracting archive
- Installing doctrine/dbal (3.7.2): Extracting archive
- Installing composer/semver (3.4.0): Extracting archive
- Upgrading bfinlay/laravel-excel-seeder (v1.2.2 => v3.3.3): Extracting archive
6 package suggestions were added by new dependencies, use `composer suggest` to see details.
Package fruitcake/laravel-cors is abandoned, you should avoid using it. No replacement was suggested.
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: bfinlay/laravel-excel-seeder
Discovered Package: facade/ignition
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel/sail
Discovered Package: laravel/sanctum
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
84 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan vendor:publish --tag=laravel-assets --ansi --force
No publishable resources for tag [laravel-assets].
Publishing complete.
No security vulnerability advisories found.
And in last, I create the seeder, the excel, configure it and run it with the error:
Error
Class "bfinlay\SpreadsheetSeeder\Tests\Workaround\RefreshDatabase\RefreshDatabaseMySqlConnection" not found
at C:\Users\Alberto\Desktop\laravel_excel\laravel_excel_seeder\vendor\bfinlay\laravel-excel-seeder\src\SpreadsheetSeederServiceProvider.php:101
97▕ ];
98▕
99▕ foreach($connections as $driver => $class) {
100▕ Connection::resolverFor($driver, function($pdo, $database = '', $tablePrefix = '', array $config = []) use ($driver, $class) {
➜ 101▕ $connection = new $class['connection']($pdo, $database, $tablePrefix, $config);
102▕ $connection->setSchemaGrammar(new $class['schemaGrammar']);
103▕
104▕ return $connection;
105▕ });
1 C:\Users\Alberto\Desktop\laravel_excel\laravel_excel_seeder\vendor\laravel\framework\src\Illuminate\Database\Connectors\ConnectionFactory.php:273
bfinlay\SpreadsheetSeeder\SpreadsheetSeederServiceProvider::bfinlay\SpreadsheetSeeder\{closure}(Object(Closure), "databasetest-name", "")
2 C:\Users\Alberto\Desktop\laravel_excel\laravel_excel_seeder\vendor\laravel\framework\src\Illuminate\Database\Connectors\ConnectionFactory.php:76
Illuminate\Database\Connectors\ConnectionFactory::createConnection("mysql", Object(Closure), "databasetest-name", "")
After all, debugging, the problem is in https://github.com/bfinlay/laravel-excel-seeder/blob/e3d71d828b4612f0e5a410421919b48b9786698f/src/SpreadsheetSeederServiceProvider.php#L78-L88
My PHP version is PHP 8.0.17
and meets the two conditions of the if, so it´s return the RefreshDatabaseMySqlConnection::class;
and throw error.
If I comment this lines, the method returns MySqlConnection::class;
and the imports works like a charm.
Thank you for looking into it.
For the first part of your problem, I ran the first 2 steps but did not get the behavior of version conflicts. I am using php 8.2 in my test. From your composer output it seems that the dependency constraints around php version could plausibly be a reason.
I have all php versions and laravel versions test in the unit tests via github actions: https://github.com/bfinlay/laravel-excel-seeder/actions/runs/7051888423
These all have passed, but I had to rerun today because the previous logs have expired. I noticed that it is using v2.3.1 in the tests so I will look at that later. [update: it is actually bfinaly/laravel-excel-seeder-test-data that is installed with v2.3.1. The tests for the main package bfinlay/laravel-excel-seeder run against the latest commit, of course. So this is ok, and you can reference the test logs above to see the package tested against php 8.0 and laravel 8.0.]
composer create-project laravel/laravel:^8.0 issue-22
resulting composer.json
(excerpt)
...
"require": {
"php": "^7.3|^8.0",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^8.75",
"laravel/sanctum": "^2.11",
"laravel/tinker": "^2.5"
},
"require-dev": {
"facade/ignition": "^2.5",
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^5.10",
"phpunit/phpunit": "^9.5.10"
},
...
composer require bfinlay/laravel-excel-seeder
composer output (excerpt):
./composer.json has been updated
Running composer update bfinlay/laravel-excel-seeder
Loading composer repositories with package information
Updating dependencies
Lock file operations: 12 installs, 0 updates, 0 removals
- Locking bfinlay/laravel-excel-seeder (v3.3.3)
- Locking composer/semver (3.4.0)
- Locking doctrine/cache (2.2.0)
- Locking doctrine/dbal (3.7.2)
- Locking doctrine/deprecations (1.1.2)
- Locking doctrine/event-manager (2.0.0)
- Locking ezyang/htmlpurifier (v4.17.0)
- Locking maennchen/zipstream-php (3.1.0)
- Locking markbaker/complex (3.0.2)
- Locking markbaker/matrix (3.0.1)
- Locking phpoffice/phpspreadsheet (1.29.0)
- Locking psr/cache (3.0.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 12 installs, 0 updates, 0 removals
- Installing markbaker/matrix (3.0.1): Extracting archive
- Installing markbaker/complex (3.0.2): Extracting archive
- Installing maennchen/zipstream-php (3.1.0): Extracting archive
- Installing ezyang/htmlpurifier (v4.17.0): Extracting archive
- Installing phpoffice/phpspreadsheet (1.29.0): Extracting archive
- Installing psr/cache (3.0.0): Extracting archive
- Installing doctrine/event-manager (2.0.0): Extracting archive
- Installing doctrine/deprecations (1.1.2): Extracting archive
- Installing doctrine/cache (2.2.0): Extracting archive
- Installing doctrine/dbal (3.7.2): Extracting archive
- Installing composer/semver (3.4.0): Extracting archive
- Installing bfinlay/laravel-excel-seeder (v3.3.3): Extracting archive
5 package suggestions were added by new dependencies, use `composer suggest` to see details.
resulting composer.json
(Excerpt):
...
"require": {
"php": "^7.3|^8.0",
"bfinlay/laravel-excel-seeder": "^3.3",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^8.75",
"laravel/sanctum": "^2.11",
"laravel/tinker": "^2.5"
},
"require-dev": {
"facade/ignition": "^2.5",
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^5.10",
"phpunit/phpunit": "^9.5.10"
},
...
php -v
PHP 8.2.1 (cli) (built: Jan 5 2023 19:28:02) (NTS) Copyright (c) The PHP Group Zend Engine v4.2.1, Copyright (c) Zend Technologies with Xdebug v3.2.0, Copyright (c) 2002-2022, by Derick Rethans with Zend OPcache v8.2.1, Copyright (c), by Zend Technologies
Note that for the second command, the expected use case is:
composer require --dev bfinlay/laravel-excel-seeder
so that the package is included as a dev dependency. This is because seeding is most often expected to be used in development and testing and so it is not deployed in the production deployment.
Potentially the reason that the class is not found is because it is a workaround class that is only needed to fix a laravel bug in laravel 6, 7, and 8 that only happens under php 8.x when using the RefreshDatabase trait in a unit test. It is only needed when running unit tests and not when in production. The test classes are only included in a dev composer install.
"autoload-dev": {
"psr-4": {
"bfinlay\\SpreadsheetSeeder\\Tests\\": "tests/"
}
},
If you are doing a default composer update with dev dependencies so that the test classes are available I expect that it would still work, though.
In order to use in production environment, what I could potentially do is add a further guard to check if tests are being run before returning the workaround class.
Do you have the test classes in the vendor folder? vendor/bfinlay/laravel-excel-seeder/tests/Workaround
What does your composer install
or composer update
command look like? Are you using composer install --no-dev
?
What is your composer version? composer --version
Note that for the second command, the expected use case is:
composer require --dev bfinlay/laravel-excel-seeder
so that the package is included as a dev dependency. This is because seeding is most often expected to be used in development and testing and so it is not deployed in the production deployment.
I don´t include the --dev
because the first time the web go to production, the database it´s recreate with migrations and seeders, so the package need to go to production.
Do you have the test classes in the vendor folder? vendor/bfinlay/laravel-excel-seeder/tests/Workaround
Yep, the class it´s in its folder:
I see in composer.json
that this class autoload only in dev https://github.com/bfinlay/laravel-excel-seeder/blob/975187959b6fea5c753e971522acd2e9a92c24f3/composer.json#L36-L45 and perhaps, even if the class file exists, composer does not do the autoload
I change the install to the dev section but, the problm is the same:
PS C:\Users\Alberto\Desktop\laravel_excel\laravel_excel_seeder> composer require --dev bfinlay/laravel-excel-seeder:^3.0
bfinlay/laravel-excel-seeder is currently present in the require key and you ran the command with the --dev flag, which will move it to the require-dev key.
Do you want to move this requirement? [no]? yes
./composer.json has been updated
Running composer update bfinlay/laravel-excel-seeder
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Writing lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Package fruitcake/laravel-cors is abandoned, you should avoid using it. No replacement was suggested.
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Generating optimized autoload files
...
resulting composer.json (excerpt)
"require": {
"php": "^7.3|^8.0",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^8.75",
"laravel/sanctum": "^2.11",
"laravel/tinker": "^2.5"
},
"require-dev": {
"bfinlay/laravel-excel-seeder": "^3.0",
"facade/ignition": "^2.5",
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^5.10",
"phpunit/phpunit": "^9.5.10"
},
I checked ther autoload files from vendor/composer/autoload_*.php
and any of the files has the RefreshDatabaseMySqlConnection
from tests
autoload_classmap.php
autoload_psr4.php
autoload_static.php
Are you using
composer install --no-dev
?No, using normal composer installs
What is your composer version?
composer --version
Composer version 2.6.3 2023-09-15 09:38:21
Thank you. Good job checking the autoload file which was the info I needed to realize that composer does not include autoload-dev from child packages.
Reviewing the code, it looks like the workaround class would be helpful outside of my package tests, so I will move it out of the test namespace. The workaround class is only useful when running tests so I will put that guard on it. I may also add a guard to not override the connection class if it has already been overriden by a different package.
this workaround was introduced to fix issue #19 and provide backwards compatibility for laravel 6, 7, 8.
This is fixed in v3.3.4.
RefreshDatabaseMySqlConnection class was not included in apps because the test namespace was in autoload-dev, which does not get included in the parent.
Moved RefreshDatabaseMySqlConnection class out of the test namespace.
Added condition to check that tests are running before returning the RefreshDatabaseMySqlConnection class.
Added tests in github actions to create a new application, include the package, and run migration and seed to catch issues like this in the future.
Also updated the readme to document that the -W switch is needed when running
composer require
.
Let me know if it works for you.
The github actions tests also show that it works with all of the supported php, laravel, and dbal version configurations. https://github.com/bfinlay/laravel-excel-seeder/actions
You can see the PHP 8.0, Laravel 8.x, dbal 3.x results here: https://github.com/bfinlay/laravel-excel-seeder/actions/runs/7081280955/job/19270338824
Closing this issue, but feel free to update. Let me know if the new version works for you.
Updated to v3.3.4 and it works correctly.
Thank you so much!
How to solve this error in my laravel ?
Error Class "bfinlay\SpreadsheetSeeder\Tests\Workaround\RefreshDatabase\RError Class "bfinlay\SpreadsheetSeeder\Tests\Workaround\RefreshDatabase\RefreshDatabaseMySqlConnection" not found