There is no problem not worth solving, and no technology not worth learning!

In Laravel 6, when defining a route, use the global config function to access the configuration value

打印输出 '/' . config('filesystems.disks.theme-asset-cdn.root') . '{theme_id}/{asset_key}' ,其值为:/static/store/{theme_id}/{asset_key} 。且能够执行到对应的控制器方法。符合预期

1. In Laravel 6, define the route as follows


Route::get('/static/xxx/{theme_id}/{asset_key}', 'ThemeAssetController@show')->where('asset_key', '.*')->middleware('cache.headers:public;max_age=31536000;etag');


2. Now you need to adjust /static/xxx to get the value from the environment variable, that is, use the global config function to access the configuration value


Route::get('/' . config('filesystems.disks.theme-asset-cdn.root') . '{theme_id}/{asset_key}', 'ThemeAssetController@show')->where('asset_key', '.*')->middleware('cache.headers:public;max_age=31536000;etag');


3. Print output/ / *. config(filesystems.disks.theme-asset-cdn.root) .{theme_id}/{asset_key}, its value is: /static/xxx/{theme_id}/{asset_key} . and the corresponding controller method can be executed. in line with expectations. as shown in Figure 1

打印输出 '/' . config('filesystems.disks.theme-asset-cdn.root') . '{theme_id}/{asset_key}' ,其值为:/static/xxx/{theme_id}/{asset_key} 。且能够执行到对应的控制器方法。符合预期
Figure 1

/static/xxx/{theme_id}/{asset_key}


4. When/ / *. config(filesystems.disks.theme-asset-cdn.root) .{theme_id}/{asset_key}The value is: /static/theme-2.0-test/xxx/{theme_id}/{asset_key}. The corresponding controller method can be executed. in line with expectations. as shown in Figure 2

当 '/' . config('filesystems.disks.theme-asset-cdn.root') . '{theme_id}/{asset_key}' 的值为:/static/theme-2.0-test/xxx/{theme_id}/{asset_key}。能够执行到对应的控制器方法。符合预期
Figure 2

PHP / Laravel / Yii2 Legacy Project Maintenance & Long-Term Technical Support

If your PHP / Laravel / Yii2 project is already in production but needs bug fixing, API troubleshooting, performance optimization, developer handover support, or long-term maintenance, feel free to contact me for remote technical support.

Ideal For:
✅ PHP legacy systems without active maintenance
✅ Laravel / Yii2 project bug fixes
✅ Admin panel feature iterations
✅ RESTful API troubleshooting
✅ MySQL / Redis / Nginx performance issues
✅ Long-term remote part-time maintenance

We can start with a small task:
✅ Production error troubleshooting
✅ API issue analysis
✅ Slow query and performance bottleneck diagnosis
✅ Initial code structure review
✅ Deployment environment and log inspection

If you would like to discuss your project, please contact me and mention: PHP Maintenance Consultation.

Contact Me:
Telegram: @shuijingwan
WeChat: 13980074657
Email: shuijingwanwq@gmail.com

评论

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.