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')]);
Related
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 decided to use Directus as a Headless CMS in one of our projects. For storing media files we decided to use AWS S3 as a storage adapter. I have followed all instructions from Directus documentation how to setup the configurations for S3 but i am keeping on getting this error:
message: "No permission to write: 122d303f-b69a-48f8-8138-8f3404b3c992.jpg"
I have tried the AWS S3 bucket from CLI commands, and i can upload files there and list the files but from Directus i am having the no permission to write error.
Storage configuration in Directus looks like this:
'storage' => [
'adapter' => 's3', // What storage adapter to use for files
// Defaults to the local filesystem. Other natively supported
// options include: Amazon S3, Aliyun OSS, Azure
// You'll need to require the correct flysystem adapters through Composer
// See https://docs.directus.io/extensions/storage-adapters.html#using-aws-s3
'root' => '/originals', // Where files are stored on disk
'thumb_root' => '/thumbnails', // Where thumbnails are stored on disk
'root_url' => '##S3_URL##/originals', // Where files are accessed over the web
// 'proxy_downloads' => false, // Use an internal proxy for downloading all files
// S3
////////////////////////////////////////
'key' => '##S3_KEY##',
'secret' => '##S3_SECRET##',
'region' => '##S3_REGION##',
'version' => 'latest',
'bucket' => '##S3_BUCKET##',
'options' => [
'ACL' => 'public-read',
'CacheControl' => 'max-age=604800'
],
],
Anyone can give any insight on this?
Thanks in advance.
Need to add the following
'options' => [
'ACL' => 'private',
],
I found that I did not need the bucket policy update. Just need to add this to the config.php when trying to upload to a private bucket.
I had the same issue.
In my case, I've allowed "s3:PutObjectAcl" on the bucket and it starts working :)
It seems that this is a flysystem issue.
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 am trying to load the local version of my database.php file located in my app/config/local directory.
I have setup my $env environment detection in start.php for local.
$env = $app->detectEnvironment(array(
'local' => array('your-machine-name')
));
The correct environment appears to be detecting correctly as the result of using:
App::environment('local')
evaluates as TRUE, however it only loads the default database.php in the app/config directory.
Just in case it was still related to detection I have tried just hardcoding local as the environment, but it has the same effect.
$env = $app->detectEnvironment(function()
{
return 'local';
});
I also tried using a different name for the environment in case 'local' had some undocumented reserved meaning.
I have successfully setup environments in other projects using Laravel 4, and I can't work out for the life of me what is different in this case. I'd appreciate any suggestions on what could lead to this behaviour.
The local environment is run on MAMP.
I just did an additional test and found that app.php file in my local folder loaded correctly. It is only the local database.php file that does not appear to be loading.
Production config files are loaded first and then merged with overrides from other environments. If the production file generates an error (e.g. undefined index) the config loading will bail early without loading the overrides. Check whether it's generating an error in the log. If so, in the production config file, check the value is set before attempting to use it and the local config file will then load correctly.
In your project inside app/config directory you should create a directory named local and then in that directory you should create a file named database.php and in that fole you should provide the configuration, for example:
// File: app/config/local/database.php
return array(
'connections' => array(
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'myTestDb', // myTestDb is a db name for example
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
'pgsql' => array(
'driver' => 'pgsql',
//...
),
),
);
Then in your project_folder/bootstrap/start.php file use something like this:
$env = $app->detectEnvironment(array(
'local' => array('*.dev', gethostname()),
'production' => array('*.com', '*.net')
));
You may also check this answer for environment setup. This should work.
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.