TP5.1.35 致命錯誤: Class 'think\captcha\Captcha' not found的解決方法
步驟
1、下載安裝captcha,(注意TP5.1是2.0版本的)
2、拿到think-captcha放到verndor/topthink下
3、打開vendor/composer/autoload_psr4.php
4、composer下添加autoload_files.php
5、編輯autoload_static.php
6、編輯autoload_real.php
7、好了,可以正常調用了
1、下載安裝captcha,(注意TP5.1是2.0版本的)
composer require topthink/think-captcha 2.*
2、拿到think-captcha放到verndor/topthink下
3、打開vendor/composer/autoload_psr4.php
加入 ‘think\captcha\’ => array($vendorDir . ‘/topthink/think-captcha/src’),
autoload_psr4.php
return array(
'think\\composer\\' => array($vendorDir . '/topthink/think-installer/src'),
'think\\captcha\\' => array($vendorDir . '/topthink/think-captcha/src'),
'app\\' => array($baseDir . '/application'),
);
1
2
3
4
5
4、composer下添加autoload_files.php
autoload_files.php
<?php
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'1cfd2761b63b0a29ed23657ea394cb2d' => $vendorDir . '/topthink/think-captcha/src/helper.php',
);
1
2
3
4
5
6
7
8
5、編輯autoload_static.php
添加以下代碼
public static $files = array (
'1cfd2761b63b0a29ed23657ea394cb2d' => __DIR__ . '/..' . '/topthink/think-captcha/src/helper.php',
);
...
array (
'think\\composer\\' => 15,
'think\\captcha\\' => 14,
),
...
'think\\composer\\' =>
array (
0 => __DIR__ . '/..' . '/topthink/think-installer/src',
),
'think\\captcha\\' =>
array (
0 => __DIR__ . '/..' . '/topthink/think-captcha/src',
),
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
6、編輯autoload_real.php
查看自己autoload_static.php類名,并添加添加函數composerRequirec6c13346c3bda597899f762f41f5ad54調用
public static function getLoader()
{
...
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\自己的autoload_static.php的類名::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequirec6c13346c3bda597899f762f41f5ad54($fileIdentifier, $file);
}
return $loader;
}
//添加函數
function composerRequirec6c13346c3bda597899f762f41f5ad54($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
7、好了,可以正常調用了
結果:
————————————————
版權聲明:本文為CSDN博主「RCX明」的原創文章,遵循CC 4.0 BY-SA版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/ruancexiaoming/article/details/89606563

浙公網安備 33010602011771號