在没有转储自动加载的情况下在laravel中加载自定义类

时间:2016-11-08 09:43:47

标签: php laravel-4 autoload

我在_fileName = [NSString stringWithFormat:@"Record_%@.m4a",[DateAndTimeUtil stringFromDate:[NSDate date] withFormatterString:@"HH_mm_ss_dd_MM_yyyy"]];NSArray *pathComponents = [NSArray arrayWithObjects: [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject], _fileName, nil]; NSURL *outputFileURL = [NSURL fileURLWithPathComponents:pathComponents]; // Setup audio session AVAudioSession *session = [AVAudioSession sharedInstance]; [session setCategory:AVAudioSessionCategoryPlayAndRecord error:nil]; // Define the recorder setting NSMutableDictionary *recordSetting = [[NSMutableDictionary alloc] init]; [recordSetting setValue:[NSNumber numberWithInt:kAudioFormatMPEG4AAC] forKey:AVFormatIDKey]; [recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey]; [recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey]; // Initiate and prepare the recorder audioRecorder = [[AVAudioRecorder alloc] initWithURL:outputFileURL settings:recordSetting error:nil]; audioRecorder.delegate = self; audioRecorder.meteringEnabled = YES; [audioRecorder prepareToRecord];` 下有目录/libraries/。库假设包含所有自定义文件和类。我在那里推出了新文件,但它不起作用,因为我需要/app/ ..问题是我不能这样做。无法访问终端等。

我在dump-autoload

中有这个
composer.json

从一开始就在库中的另一个文件正常工作。

我的问题是如何加载这个新文件?

1 个答案:

答案 0 :(得分:0)

你可以试试我最近尝试过的东西,它对我有用。导航至vendor/composer/。既然您已经说过在图书馆中有一个php文件并且它正在工作,这意味着您将在后续文件中使用它,您可以复制/粘贴这些行并随文件一起更改。

首先打开文件autoload_classmap.php并添加到数组的底部

'yourfile' => $baseDir . '/app/libraries/yourfile.php',

第二个打开的文件autoload_static.php,并在底部再次添加您的文件

public static $classMap = array (
    ...
    'yourfile' => __DIR__.  '/../..' . '/app/libraries/yourfile.php',

保存两个文件并重新加载。在我的情况下,这加载文件而不需要自动转储。

相关问题