I can't figure out, how to use Yii's default messages, without overwriting them with the message command.
I have 2 translation categories: app, data.
I'd like to use the default messages, like "Are you sure you want to delete this item?" and "(not set)" from the Yii2 core, but if I use Yii::t('yii', 'Are you sure you want to delete this item?') and then run the yii message command, it creates a yii.php file in the messages folder with this token.
Part of my config:
'i18n' => [
'translations' => [
'app*' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '#app/messages',
],
'data*' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '#app/messages',
],
],
],
How should I set up my config to use the built in texts and not to overwrite them?
You don't have to do anything. The yii-category is automatically defined as soon as you use translation and it points to the messages in the framework.
That it creates an empty file is for 'yii' is normal, because you actually use that category in your code. This is unrelated to where the messages will be loaded from during normal execution.
Just make sure that you configure your apps' language and sourceLanguage correctly if not already done.
Related
I’ve got a Problem with spam protection in TYPO3 v9.5 for a long time in my own template extension and custom content elements.
I would expect, that the E-Mail Links inserted via TypoLink in ckEditor would be transformed to name(at)domain.de in the frontend by using the following snippet in my Setup. But its simply is ignored:
config.spamProtectEmailAddresses = 2
config.spamProtectEmailAddresses_atSubst = <span>(at)</span>
I’ve set up a clean Installation with 9.5.15 and it just works. So I think it has something to do with my template-extension or my custom components with custom ckEditor config.
Can someone with a better understanding of TYPO3 please guide me to the right direction?
Here is my TCA for the Textfield:
'bodytext' => [
'exclude' => true,
'label' => 'Kontaktdaten',
'config' => [
'type' => 'text',
'cols' => 40,
'rows' => 3,
'softref' => 'rtehtmlarea_images,typolink_tag,email[subst],url',
],
'defaultExtras' => 'richtext:rte_transform[flag=rte_enabled|mode=ts_css]'
],
compare your TCA field configuration with the configuration of the field tt_content.bodytext
I guess you missed: config.softref = typolink_tag,images,email[subst],url
Currently my config/logging.php channels section contains like the following:
'stack' => [
'driver' => 'stack',
'channels' => ['single', 'slack'],
],
Then in my slack section I have set a webhook using the Incoming Webhooks section in Slack. https://slack.com/apps/A0F7XDUAZ-incoming-webhooks
Other incoming webhooks I've set for other application (not Laravel) have all worked perfectly.
When I call the following:
Log::channel('stack')->info('test'); then it successfully logs to the file, but not to Slack.
or
Log::channel('slack')->info('test'); just seemingly does nothing.
In my Slack channels as I add the configuration I can see the notification "added an integration to this channel: Laravel Log"
Not sure what else to do to even troubleshoot this or get it working?
Make sure info is not below the specified minimum level for messages to be escalated to Slack in config/logging.php.
if the channel level is on the debug, all kinds of log functions work.
the following levels can be used for logs in order of importance
1- emergency
2-alert
3-critical
4-error
5-warning
6-notice
7-info
8-debug
and if the level you used in the channel settings should be higher than the log level. The log does not work
For example, if the channel level settings are critical
Log::error($message);
Log::warning($message);
Log::notice($message);
Log::info($message);
Log::debug($message);
does not work
But
Log::emergency($message);
Log::alert($message);
Log::critical($message);
they are working.
So if the channel level is on the debug, all kinds of log functions work.
'slack_channel' => [
'driver' => 'slack',
'url' => 'https://hooks.slack.com/services/.....',
'username' => 'Laravel Log',
'emoji' => ':boom:',
// 'level' => 'critical',///<---- in critical level it`s work for Log::channel('slack_channel')->critical('message') || alert('message') || emergency('message')
'level' => 'debug',///<---- in debug level it`s work for each type log. for example Log::channel('slack_channel')->debug('message') || info('message') || notice('message') .... emergency('message')
],
Using Laravel 5.3 and v4 from spatie/laravel-backup package.
I am using this package from Spatie which allows me to take backups using a simple terminal command. It is pretty straight forward to set up and when I run the command the backup runs as intended.
But there is also an option in the config file to set notifications (send mail, post to slack, ...) after a backup. This does not seem to do anything for me. I neither receive mails (and I have set my mailaddress) or see posts to my dedicated slack channel (and i have added the webhook).
I have already included the following composer packages since researching this problem:
Guzzlehttp/guzzle
maknz/slack-laravel
maknz/slack
This is the simple notifications section in the config file:
'notifications' => [
'notifications' => [
\Spatie\Backup\Notifications\Notifications\BackupHasFailed::class => ['mail'],
\Spatie\Backup\Notifications\Notifications\UnhealthyBackupWasFound::class => ['mail'],
\Spatie\Backup\Notifications\Notifications\CleanupHasFailed::class => ['mail'],
\Spatie\Backup\Notifications\Notifications\BackupWasSuccessful::class => ['mail'],
\Spatie\Backup\Notifications\Notifications\HealthyBackupWasFound::class => ['mail'],
\Spatie\Backup\Notifications\Notifications\CleanupWasSuccessful::class => ['mail'],
],
/*
* Here you can specify the notifiable to which the notifications should be sent. The default
* notifiable will use the variables specified in this config file.
*/
'notifiable' => \Spatie\Backup\Notifications\Notifiable::class,
'mail' => [
'to' => 'nicolas#******.***',
],
'slack' => [
'webhook_url' => 'https://hooks.slack.com/services/*****/*****/*************',
],
],
Not really sure if I am forgetting something? Thanks for the help
The output I get in terminal after running the commands: gist.github
Extra:
This is a talk at Laracon EU 2016, where the creator (Freek) shows off his package.
How can I change default log file location <project-name>/storage/logs/laravel.log to something like /var/logs/<project-name>/laravel.log?
I resolved this case by using errorlog logging model and configuring webserver.
1. Configure Laravel:
In config/app.php configuration file:
'log' => 'errorlog'
Read more about Laravel log configuration: http://laravel.com/docs/5.1/errors#configuration
2. Configure webserver (in my case Nginx):
error_log /var/log/nginx/<project_name>-error.log;
For those who don't want to use errorlog and just really want to replace the file to log to, you can do this:
\Log::useFiles(env('APP_LOG_FILE'), config('app.log_level', 'debug'));
$handlers = \Log::getMonolog()->getHandlers();
$handler = array_shift($handlers);
$handler->setBubble(false);
on App\Providers\AppServiceProvider.php or any Provider for that matter. This will log to the value of APP_LOG_FILE instead of the default laravel.log. Set bubbling to true and the application will log on both files.
For anyone still coming across this post in hopes of changing their log file location, I believe this is now easier in newer versions of Laravel. I am currently using 8.x
In your /config/logging.php you can define the path for your single and daily logs. Just update whichever one your are looking to change. Just make sure you also include the name of the log file, not just the path to where you'd like it saved.
'single' => [
'driver' => 'single',
'path' => "/your/desired/log/path/file.log", // edit here
'level' => env('LOG_LEVEL', 'debug'),
],
'daily' => [
'driver' => 'daily',
'path' => "/your/desired/log/path/file.log", // edit here
'level' => env('LOG_LEVEL', 'debug'),
'days' => 14,
]
OK, i know this question has been asked many times, however not one of the answers seems to work, i can only assume Yii2 has been updated since then.
Here goes:
I am trying to change the frontend theme of my Yii2 Advance Application.
I chose a theme from http://yii2.themefactory.net/
I downloaded the theme and completed the following steps that i have found on various sites on the web.
Created a folder myApp/frontend/themes
Placed the files from the download into this folder
Changed the myApp/frontend/config/main.php to include the following
'view' => [
'theme' => [
'pathMap' => [
'#app/views' => '#app/themes/interior'
],
'baseUrl' => '#web/themes/interior',
],
],
I have tried various ways of the baseUrl. and it doesn't seem to find the CSS file, as i have read the theme files shouldn't be placed in the web folder.
However i cannot see anyway of reading these CSS files without them being placed in the web folder.
So do i have to split the theme and place the views in the theme folder and then the CSS in another folder under the web folder.
Sorry if this makes no sense, but i have read so many posts across so many sites that all contradict each other.
Let me know any thoughts
Thanks.
Further information.
The issue seems to be that the themes folder myApp/frontend/themes contains all the theme files including the CSS. When the website is run it cannot link to these CSS files.
So is the answer that i need to split the themes folder, keep the layouts in the myApp/frontend/themes and then put the CSS in a similar folder in myApp/frontend/web/themes ??
** OK Solution - However i am not sue this is the correct way **
In the theme folder i downloaded there was two folders layouts and files
I created two folders myApp/frontend/themes and myApp/frontend/web/themes
I put the layouts folder into the mayApp/frontend/themes/THEME_NAME folder and the files folder into myApp/frontend/themes/web/THEME_NAME/ folder
I then setup the main.php confgi file like this
'view' => [
'theme' => [
'pathMap' => ['#app/views' => '#app/themes/houses-on-water'],
'baseUrl' => '#web/themes/houses-on-water',
],
],
I am not sure this is the correct way but it is working
Regards
Liam
Copy content in:
MYAPP/frontend/web/themes/MYTHEME
Change your MYAPP/frontend/config/main.php
'view' => [
'theme' => [
'pathMap' => [
//Only for change layout/main.php location
'#app/views' => '#webroot/themes/MYTHEME'
],
'baseUrl' => '#web/themes/MYTHEME',
'basePath' => '#webroot/themes/MYTHEME',
],
],
Reference:
https://www.yiiframework.com/wiki/667/yii-2-list-of-path-aliases-available-with-default-basic-and-advanced-app
https://www.yiiframework.com/doc/guide/2.0/en/output-theming
Enjoy
For frontend try changing this way:
'view' => [ 'theme' => [
'pathMap' => [ '#frontend/views' => '#frontend/themes/interior' ],
'baseUrl' => '#web/themes/interior'],
],
Just use theme under web/themes folder, and change your code to this :
'view' => [
'theme' => [
'pathMap' => ['#app/views' => '#app/web/themes/houses-on-water'],
'baseUrl' => '#web/themes/houses-on-water',
],
],
It's work to me.