Ok so I have setup an advanced application in Yii2 and it is all working but now I want to install my own bootstrap which has 48 cols and a gutter width of 20px.
The only way I currently see is to actually maintain my own repo of it in GitHub or something.
What is the best way with composer controlling everything I do to achieve this?
Currently the best way I can see is to add this to your config:
'assetManager' => [
'bundles' => [
'yii\bootstrap\BootstrapAsset' => [
'sourcePath' => null,
'css' => ['css/bootstrap.css']
],
],
],
I am completely open to better suggestions.
Related
I want to integrate Elasticsearch into my Laravel project hence i have setup Elastic search inside my Local machine and it is working fine,
I am using
ddev
as a development environment
then I have installed Laravel Version 9 and elastic seach package using
composer require cviebrock/laravel-elasticsearch
Note: when I am running http://localhost:9200/ it is showing successful response hence elastic search is installed perfectly
when I try to use below code
$response = Elasticsearch::search([
'index' => 'books',
'body' => [
'query' => [
'multi_match' => [
'query' => "Dormouse,' the.",
'fields' => [
'title'
]
]
]
]
]);
I got an error
Elasticsearch\Common\Exceptions\NoNodesAvailableException : No alive nodes found in your cluster
First, I recommend that you use the DDEV add-on ddev-elasticsearch, which will get you going faster. ddev get drud/ddev-elasticsearch. Follow the instructions at https://github.com/drud/ddev-elasticsearch to learn more. You'll be a lot better off with elasticsearch running inside DDEV as in this solution.
From there, you'll need to know how to configure Laravel, but you should be able to do fine with it.
hope you are doing well
I'm having the problem with Laravel Cache
First , this only happened on my produyction server (Windows 10 Server)
It seems that the apps can't i put a Cache which comming from PHPSpreadsheet Excel Object.
I already tried it with array or php objects, and they are all fine
Cache::put($cacheKey, $spreadsheet, now()->addMinutes(2));
Cache setting :
'default' => env('CACHE_DRIVER', 'file'),
'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache/data'),
],
I assume if i can put thearray and php object , then there is nothing wrong with the folder permission.
How to solve this ?
I'm trying to embed a logo as an image in email.
When i use the <img src="{{ $message->embed($pathToImage) }}"> function i get an error
Unable to open file for reading [https://roadshow.test/storage/img/Email/Image_1_3a24d02162cb4c38a9c97009d527d53c.png]
The Email builder look like this:
return $this->subject("Event - {$subjectDate}")
->view('emails.index')
->with(['pathToImage' => url('/storage/img/Email/Image_1_3a24d02162cb4c38a9c97009d527d53c.png')]);
If i use the url('....') function in my View, the picture is loading and I can see it without any problems.
I have also tried to get the image with the Laravel public_path('/img/Email/Image_1_3a24d02162cb4c38a9c97009d527d53c.png') helper. But this is not working altought i linked the storage with public folder with the php artisan command.
my filesystem config:
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
and I don't use a email markdown. The enviroment is set up on homestead. All my files are in "/home/vagrant/code/roadshow/storage/img/Email/Image_1_3a24d02162cb4c38a9c97009d527d53c.png" folder uploaded.
I'm running homestead on Windows 10 and this is the path in Windows
In your email builder, the name of the attribute hint for a path not a link.
Try it with the direct path, since you are embedding the image to your mail body.
return $this->subject("Event - {$subjectDate}")
->view('emails.index')
->with(['pathToImage' => storage_path('app/public/img/Email/Image_1_3a24d02162cb4c38a9c97009d527d53c.png')]);
I've built a piece of software which uses Laravel config module to consume certain settings.
Thing is, we're using Laravel Forge to auto-deploy, and everytime we deploy, configs are reset to the "blank" state, thus breaking some things everytime I deploy.
I have added the files to .gitignore, but doesn't seem to do the trick.
Can anyone point me towards the right direction in order to save this config files without having the re-set them everyime we deploy?
Thanks everyone!
It would be helpful to have an example of your config and .env files
Config files for multiple environments rely on .env files in each environment.
env() returns either the matching variable from your .env or the value specified.
so env('QUEUE_DRIVER', 'sqs') would look into the .env file for the QUEUE_DRIVER variable if it can't find a variable it returns the default 'sqs'.
An example of a queue config file might looks like this.
config/queue.php
<?php
return [
'default' => env('QUEUE_DRIVER', 'sqs'),
'connections' => [
'sync' => [
'driver' => 'sync',
],
'sqs' => [
'driver' => 'sqs',
'key' => env('SQS_KEY'),
'secret' => env('SQS_SECRET'),
'prefix' => env('SQS_URL'),
'queue' => 'general_queue',
'region' => 'us-east-1',
],
],
];
You would then set your variables in your .env file for each environment.
Production may look like this.
.env
QUEUE_DRIVER=sqs
SQS_KEY=yoursqskey
SQS_SECRET=yoursqssecret
SQS_URL=yoursqsurl
Your local environment might look like this.
.env
QUEUE_DRIVER=sync
You can edit your .env file in forge under Sites > Site Details > Environment
I have designed Yii2 powered blog by creating models, views and controllers but when I integrate user registration as explained in this tutorial https://code.tutsplus.com/tutorials/how-to-program-with-yii2-integrating-user-registration--cms-22974 I get:
Class dektrium\user\Module does not exist
I fail to solve this error anyone who can direct me, please.
I think you need to include the required module via composer:
"dektrium/yii2-user": "*"
Then run the "composer update" command in your console.
Mabe you need to add to config:
'user' => [
'class' => 'dektrium\user\Module',
'admins' => ['MegaAdmin'],
],
If you have it in common/config/main.php try to replace to backend/config/main.php