简体   繁体   English

公用文件夹内的调用方法-Laravel

[英]Call methods inside public folder - Laravel

I am using Responsive Filemanager and Tinymce in my laravel multisite project. 我在laravel多站点项目中使用响应式文件管理器和Tinymce。 Those files are in my public folder and the filemanager uses config.php file to setup upload directory. 这些文件位于我的公共文件夹中,并且filemanager使用config.php文件设置上传目录。 For every site I want to use different upload folder. 对于每个站点,我要使用不同的上载文件夹。 What i want to do is dynamically change the upload directory using by using some method eg 我想做的是通过使用某种方法动态地更改上传目录,例如

Config::get('upload.foldername');

or 要么

Session::get('site.foldername');

How do i do that? 我怎么做?

app/config/upload.php looks like this app / config / upload.php看起来像这样

<?php
return array(
    'foldername' => 'site1'
);

if the url is site2.example.com, I change the config file from my filter 如果网址是site2.example.com,则从过滤器中更改配置文件

$host = Request::getHost();
$parts = explode('.', $host);
$subdomain = $parts[0];
Config::set('upload.foldername', $subdomain);

If you save that file with .blade.php extension, included it in your view and then call Config like this 如果您使用扩展名.blade.php保存该文件,请将其包含在视图中,然后像这样调用Config

Config::set('uppload.foldername', $subdomain); // where subdomain your get it with Request::url() or your own method

EDIT 编辑

Rename config.php to config.blade.php 将config.php重命名为config.blade.php

In config.blade.php do <?php echo Config::get('upload.foldername') ?> and wherever you want to include the config.blade.php do <?php include('path/to/config.blade.php') ?> I just tried it and it works alright 在config.blade.php中,执行<?php echo Config::get('upload.foldername') ?>并在要包含config.blade.php的任何地方执行<?php include('path/to/config.blade.php') ?>我刚刚尝试过,效果很好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM