I need your help guys. I changed directory for all Assets. It works properly, but not for bootstrap fonts.
For Ex: path for css and js file now is project/www/web_assets/all.css and Yii2 found them properly.
But it does not working for fonts. Yii2 is looking for fonts at wrong derictrory /var/www/tt_yii/web/assets/582582f3/fonts/glyphicons-halflings-regular.woff2.
Bootstrap gets used at different places. It is already configured by default by the BootstrapAsset and is a dependency for other pre-defined assets. But you can override the default location.
Assuming you have the same file structure in web_assets as it can be found in 'vendor/bower-asset/bootstrap/dist' (contains folder css, fonts and js) you can add the following to your components configuration:
use yii\bootstrap\BootstrapAsset;
...
'components' => [
...
'assetManager' => [
'bundles' => [
BootstrapAsset::class => [
'sourcePath' => null,
'baseUrl' => '#web/web_assets',
],
]
],
...
],
#web points to the web folder where the index.php and your web_assets directory file should exist as well. sourcePath gets set to null since baseUrl wouldn't be evaluated.
Further information about configuring the used bundles can be found at AssetManager::$bundles or in the guide.
Similar question is here.
Check you nginx settings. If there is a filetype list, you should insert these font types into it also:
location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar|eot|svg|ttf|woff|woff2)$
(Duplicate of bootstrap icon fonts not loading )
Related
I'm putting my Laravel project in production and I've clone it from GitHub to /home/myuser/repositories/myuser/MYPROJECT-app, and my public Laravel folder content is in /home/myuser/public_html.
I've changed (project location)/app/Providers/AppServiceProvider.php and add:
$this->app->bind('path.public', function() {
return '/home/myuser/public_html';
});
To the Register function. I changed the index.php from the public folder to match my project location and everything works well, except when I try to upload a file using the method:
Storage::disk('public')->put('myfiles/', $request->myFile)
It is stored in /home/myuser/repositories/MYPROJECT-app/public/storage/myfiles instead of /home/myuser/public_html/storage/myfiles.
(Note: I cannot use symbolic links because some restrictions with the server configuration, so I'm trying to store all the files within a storage folder within the public path).
I'm guessing I'm missing some configuration to tell Laravel to store the uploaded files in /public_html/storage instead of MYPROJECT/public/storage, but I can't find which file I have to change.
This should work for you, but I cannot assure it 100%. (I will be using Laravel 9.x).
In your config/filesystems.php, go to the disks index and add a new one just for testing purposes:
'outside' => [
'driver' => 'local',
'root' => realpath('/home/myuser/public_html'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
'throw' => false,
],
As you can see, we are using realpath('/home/myuser/public_html'), but have in mind that url requires a symlink and you said it is not possible, so you are basically done there.
Let me know if this partially works, does it works but the URL not? Can you read files, store them, etc?
I have created module "Admin" in gii generator in Yii2 (my module is named "Admin" and it could be found here app\modules\admin\Admin.php)
But how can I open this module in my browser. What url I should use.
Url https://regexp/web/index.php?r=admin returns 404
To use a module in an application, simply configure the application by listing the module in the modules property of the application. The following code in the application configuration uses the forum module:
[
'modules' => [
'admin' => [
'class' => 'app\modules\admin\Admin',
// ... other configurations for the module ...
],
],
]
The modules property takes an array of module configurations. Each array key represents a module ID which uniquely identifies the module among all modules in the application, and the corresponding array value is a configuration for creating the module.
See also Yii2 modules guide
If you have a controller named 'site' and an action named 'action', then to open them in the module 'admin', you should be able to do it with this URL: https://regexp/web/index.php?r=admin/site/action
I have a project on Yii2 advances app. And I have created a module named 'sale' on front end, Where I have extended layouts of frontend. And now I just want to access that module as a subdomain like http://sale.example.com .
I have created subdomain sale.example.com and set it's document root to root folder public_html (sites's root folder).
I have configures my urlManager like 'http://sale.example.com' => 'sale/default/index', according to Yii2 DOC. And it working fine but all my navigation gone wrong. I mean I think app's homeUrl is not pointing to default site url. My entire url system is changed after sub domains like http://sale.example.com/contact, But this is supposed to be http://example.com/contact . Here is a snapshot.
Thanks in Advance.
You can do it using UrlManager. Here is example Just replace your_module_name with real name of your module. More on UrlManager you can see here
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'enableStrictParsing' => false,
'rules' => [
'sale.example.com/<controller>/<action>' => 'your_module_name/<controller>/<action>',
],
],
I am developing an web application using Laravel 5 and AngularJS. I am using pure angularJS app for the client side and I am putting the client app files (views) in my public folder.
In Laravel 4, I could change the path from the bootstrap/start.php file. But in Laravel 5, I can not see the start.php file. So where do I change the configuration in Laravel 5?
See line 16 of config/view.php (the "View Storage Paths" section)
'paths' => [
realpath(base_path('resources/views'))
],
So you might change it to realpath(base_path('public/assets/views')) to be in your public path.
Additional Examples
'paths' => [
// src/MyNamespace/resources
realpath(base_path('src/MyNamespace/resources')),
// app/resources
realpath(app_path('resources'))
],
You can provide multiple search locations
You can use app_path(), base_path(), or neither.
I'm using the asset library that comes with pyrocms for my cms and I have a set up like this for my assets. I am trying to figure out with the paths and namespacing how I can access the bootstrap.css file correctly with the documentation.
http://docs.pyrocms.com/2.1/manual/developers/tools/assets
I have updated my asset.php configuration file to look like this:
$config['asset_paths'] = array(
'core' => 'assets/',
'globals' => 'assets/globals/'
);
This is the line I have set up in my template page to try and retrieve the bootstrap file:
<?php Asset::css('globals::bootstrap/css/bootstrap.min.css'); ?>
This is my file directory:
/root
/assets
/globals
/bootstrap
/css
bootstrap.css
It is saying the following error message.
Found no files matching
assets/globals/css/bootstrap/css/bootstrap.min.css
Any ideas on what I good fix would be for this?
I've never used the library in question, but judging on your post it appears that the library automatically checks for a css folder within the designated asset_path.
I would create a new asset path called bootstrap:
'bootstrap' => 'assets/globals/bootstrap/'
and add the CSS file as such:
Asset::css('bootstrap::bootstrap.min.css');