我的 laravel 10 在 Windows 10、VMware ubuntu 上运行良好。但在 cpanel 中不起作用。cPanel 110.0.39database\seeders\CountryXlsxSeeder.php
我的 laravel 10 在 Windows 10、VMware ubuntu 上运行良好。但在 cpanel 中不起作用。
cPanel 110.0.39
数据库\seeders\CountryXlsxSeeder.php
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Schema;
use App\Models\MasterData\Country;
use Maatwebsite\Excel\Facades\Excel;
class CountryXlsxSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Schema::disableForeignKeyConstraints();
Country::truncate();
$filename = 'database/sheets/ImportSheets/countries.xlsx';
if (is_file($filename)) {
echo "doing CountryImport";
Excel::import(new \Database\Sheets\ImportClasses\CountryImport, $filename);
}else{
echo $filename . ' file not exists';exit;
}
Schema::enableForeignKeyConstraints();
}
}
执行播种机
$ ea-php82 artisan db:seed --class=CountryXlsxSeeder
...
INFO Seeding database.
doing CountryImport
$_
为什么停在这里,并且没有任何错误信息。
裁缝网站/excel 确实存在
$ea-php82 /opt/cpanel/composer/bin/composer 显示网站大小/excel
name : maatwebsite/excel
descrip. : Supercharged Excel exports and imports in Laravel
keywords : PHPExcel, batch, csv, excel, export, import, laravel, php, phpspreadsheet
versions : * 3.1.56
type : library
license : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText
homepage :
source : [git] https://github.com/SpartnerNL/Laravel-Excel.git 0381d0225b42c3f328d90f0dd05ca071fca3953f
dist : [zip] https://api.github.com/repos/SpartnerNL/Laravel-Excel/zipball/0381d0225b42c3f328d90f0dd05ca071fca3953f 0381d0225b42c3f328d90f0dd05ca071fca3953f
path : /home/staus/public_html/laravel/vendor/maatwebsite/excel
names : maatwebsite/excel
support
issues : https://github.com/SpartnerNL/Laravel-Excel/issues
source : https://github.com/SpartnerNL/Laravel-Excel/tree/3.1.56
autoload
psr-4
Maatwebsite\Excel\ => src/
requires
composer/semver ^3.3
ext-json *
illuminate/support 5.8.*||^6.0||^7.0||^8.0||^9.0||^10.0||^11.0
php ^7.0||^8.0
phpoffice/phpspreadsheet ^1.18
psr/simple-cache ^1.0||^2.0||^3.0
requires (dev)
laravel/scout ^7.0||^8.0||^9.0||^10.0
orchestra/testbench ^6.0||^7.0||^8.0||^9.0
predis/predis ^1.1
国家进口
<?php
namespace Database\Sheets\ImportClasses;
use App\Models\MasterData\Country;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithStartRow;
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
class CountryImport implements ToModel,WithStartRow,WithMultipleSheets,WithHeadingRow
{
public function model(array $row)
{
$model = new Country([
'code' => $row['code'],
'name' => $row['name'],
'native_name' => $row['native_name'],
'iso_code_3' => $row['iso_code_3'],
]);
return $model;
}
public function startRow(): int
{
return 2;
}
public function sheets(): array
{
return [
'countries' => $this,
];
}
}