Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 06:19
    karelvasicek commented #19599
  • 06:19
    karelvasicek opened #19599
  • 06:06
    bizley closed #19598
  • Sep 28 22:16
    Arhell synchronize #19598
  • Sep 28 22:16
    Arhell review_requested #19598
  • Sep 28 22:16
    Arhell ready_for_review #19598
  • Sep 28 09:49
    Arhell labeled #19598
  • Sep 28 09:49
    Arhell opened #19598
  • Sep 28 07:45
    DSTester commented #359
  • Sep 28 06:52
    bizley commented #359
  • Sep 27 19:06
    DSTester opened #359
  • Sep 27 17:54
    WinterSilence synchronize #19528
  • Sep 27 17:51
    WinterSilence synchronize #19528
  • Sep 27 17:50
    WinterSilence review_requested #19528
  • Sep 27 17:50
    WinterSilence review_request_removed #19528
  • Sep 27 17:50
    WinterSilence review_requested #19528
  • Sep 27 17:50
    WinterSilence review_request_removed #19528
  • Sep 27 17:50
    WinterSilence review_requested #19528
  • Sep 27 17:50
    WinterSilence review_request_removed #19528
  • Sep 27 17:48
    WinterSilence synchronize #19528
Rami Serapian
@rami11
Hi everyone! How do I upgrade to bootstrap 4 in yii? Is there any helpful document that explains how to do so?
Lake
@Lachee

What is the best practice for using Access Tokens in apis?

        $identity = self::find()->where(['access_token' => $token])->select('id')->one();
        if ($identity == null) return null;

        //As per the recommendations, https://www.yiiframework.com/doc/api/2.0/yii-web-identityinterface#findIdentityByAccessToken()-detail
        // null should be re turned here.
        if (!Yii::$app->authManager->checkAccess($identity->id, Permissions::IdentifyWithAccessToken))
            return null;    

        return $identity;

this doesn't seem all that secure having it in plain text.

Alexander Makarov
@samdark
Yermek DevOps
@jhd235
https://www.yiiframework.com/extension/yiisoft/yii2-debug/doc/guide
when the "Development Tools" chapter is going to be created, please?
Kai Mindermann, M.Sc.
@kmindi
Hi, I have two models that have a many to many relation. In the create action of the controller for model A I want to create an entry in the junction table to "link" model B. Yet I get the following error: UnknownPropertyException
This is how I call the linking after the $model was saved $model is an Organisation, organisationUsers is the junctiontable/model for linking organisations to users: $model->link('organisationUsers', Yii::$app->user->identity, ['status' => 10, 'role' => 10]);.
This is the next called method in the stack trace: in /app/vendor/yiisoft/yii2/db/BaseActiveRecord.php at line 1350– yii\db\BaseActiveRecord::bindModels(['organisation_id' => 'id'], common\models\User, common\models\Organisation).
in /app/vendor/yiisoft/yii2/db/BaseActiveRecord.php at line 1574– yii\db\BaseActiveRecord::__get('organisation_id')
Kai Mindermann, M.Sc.
@kmindi
Fixed it, I was using the junction table relation instead of the relation to users
matrixbot
@matrixbot
qncm Hey. I'm populating dropdownlist for a nullable field. What should be the key here: [ ??? => 'nothing', ...]?
Nouras Hamwi
@NourasHamwi
Any idea why would isGuest and user identity only works in SiteController and not other controllers?
Nouras Hamwi
@NourasHamwi
isGuest works fine in frontend and backend but the problem is happenening when you add a third application I followed Yii2 documentation to create an additional application which works find just user identity is not working outside of sitecontroller.
Lake
@Lachee
How do I override the base MOdel class using DI?

I have tried

'container' => [
        'definitions' => [
            yii\base\Model::class => app\models\Model::class,

but that doesn't do anything. The models dont have any of the app\models\Model::class and are not instances of it

 $model = TestModel::findOne(['id' => 3]);
 $success = $model instanceof \app\models\Model;
  if (!$success) Yii::$app->session->addFlash('danger', 'failed to override');
this always fails
Alexander Makarov
@samdark
Christopher Stebe
@Quexer69

Hey guys, I have a question regarding the yiisoft/yii2-queue and the monitor extension from Roman Zhuravlev. I need to implement a worker affinity for jobs.

I start worker using supervisor in docker container (1 or many):

[group:worker]
programs=yii-queue-worker
priority=40

[program:yii-queue-worker]
command=yii queue/listen --verbose=1 --php-binary=/usr/local/bin/php --isolate=1 --color=0 --interactive=0
process_name=%(program_name)s_%(process_num)02d
autostart=true
numprocs=5
autorestart=true
startsecs=14
startretries=20
user=application
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0

So I have 5 isolated queue listeners up and running in each container / host.
Now a job A was pushed for the first time and gets executed by worker A on host A.
Then I remember (using a simple key value store in redis) that job A was processed by worker A on host A.
Works fine so far and I can access that information everywhere.

Now the next time job A comes I need to ensure that this job A will only gets executed on worker A on host A.
Until worker A on host A is busy that job A needs to wait.

I tried a lot to get that done but job A gets always executed by one of the next free available worker process.

I use own extended classes doing nothing atm then calling the parent class methods to be able to customize.
Here`s my config:

'queue' => [
            'class' => ProjectQueue::class,
            'commandClass' => ProjectCommand::class,
            'as log' => [
                'class' => ProjectLogBehavior::class,
                'autoFlush' => true,
            ],
            'as jobMonitor' => [
                'class' => ProjectJobMonitor::class,
            ],
            'as workerMonitor' => [
                'class' => ProjectWorkerMonitor::class,
            ],
            'mutex' => [
                'class' => MysqlMutex::class,
                'db' => 'db',
                'autoRelease' => false,
            ],
            'mutexTimeout' => 10,
            'db' => 'db',
            'channel' => 'master-queue', 
            'deleteReleased' => true, 
            'ttr' => 200,
            'attempts' => 1,
        ],

Now my question. Is that possible at all? And where I need to slide in to get that done.

Thanks in advance !

Alexander Makarov
@samdark
Alexander Makarov
@samdark

🎁 Yii news 2020, issue 8: https://opencollective.com/yiisoft/updates/yii-news-2020-issue-8

🎄 Happy New Year!

Alexander Makarov
@samdark
Alexander Makarov
@samdark
kiti_Nomad
@Kiti-Nomad
php
Alexander Makarov
@samdark
🔥🎁 #Yii news 2021 issue 3 is here: https://opencollective.com/yiisoft/updates/yii-news-2021-issue-3
joanav16
@joanav16
hi
i have 3 dropdowns.....exists anything in kartik that when i select one dropdown the other twos are bloqued?
1 reply
tebe
@tbreuss
I think you should address your question directly to https://github.com/kartik-v since this channel here is about the framework and not about 3rd-party extensions or plugins.
xDaemonic
@xDaemonic

Hello guys!
I have a task for writing history of changes in my little project, i had CRUD conception in my project and 2 controllers for him.
Somebody can help me with logic for this task?

i started from afterAction hook, but i dont know how to send my params in this hook

tebe
@tbreuss
@xDaemonic A code example would be helpful.
Chris
@chris453
I have a question if I have a view and right now it send to one action controller, How would i send a ajax call on that same page to use a different action should I make a route for that action its supposed to just update a table no redirecting
Andrey
@de1phi48

good day, i setup DBSession:

    'session' => [
        'class' => 'yii\web\DbSession',
        'timeout' => 3600 * 4,
        'writeCallback' => function($session)
        {
            return [
                'user_id' => Yii::$app->user->isGuest ? null : Yii::$app->user->id,
                'agent' => Yii::$app->request->userAgent,
                'ip' => ip2long(Yii::$app->request->userIP),
            ];
        }
    ],

create mysql table:

CREATE TABLE tbl_session (
id char(64) NOT NULL,
expire int(11) DEFAULT NULL,
data blob,
user_id char(36) DEFAULT NULL,
agent char(255) DEFAULT NULL,
ip int(11) UNSIGNED DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

and when user is login user_id is ignored to insert to db, in debug i have request:
NSERT INTO tbl_session (user_id, agent, ip, data, id, expire) VALUES ('ab44c918-81f3-46fc-9720-a168ce652729', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36', 168433921, 'flash|a:0:{}returnUrl|s:26:\"\";id|s:36:\"ab44c918-81f3-46fc-9720-a168ce652729\";authKey|s:12:\"a168ce652729\";', 'ha5gmmtpatjou0', 1638538767) ON DUPLICATE KEY UPDATE agent=VALUES(agent), ip=VALUES(ip), data=VALUES(data)

why user_id is ignored on "ON DUPLICATE KEY UPDATE"?
tebe
@tbreuss
I think this has to do with a missing PRIMARY or UNIQUE KEY in your database table schema:
https://dev.mysql.com/doc/refman/8.0/en/insert-on-duplicate.html
Andrey
@de1phi48

I think this has to do with a missing PRIMARY or UNIQUE KEY in your database table schema:
https://dev.mysql.com/doc/refman/8.0/en/insert-on-duplicate.html

thanks for your message, problem is solved. user_id was foreign key.

Taha Fathallah
@dRz3r00t
how to use UNSIGNED in Yii 2 , i try this Schema::Type_INTEGER.’ UNSINGED ‘ but its not working ?
tebe
@tbreuss
You are talking 'bout migrations? Maybe something like this:
$this->createTable('tableName', [
    'id' => $this->integer()->unsigned()->notNull(),
    // ...
]);
2 replies
Alexander Makarov
@samdark
🎄#yii news, issue 4: https://opencollective.com/yiisoft/updates/yii-news-2021-issue-4 🎄Merry Christmas and happy New Year! 🎄
郭贰小姐
@opqnext
??
Howie
@yohowie
hello
superherip
@superherip
It is possible to post your packages directly in the project. For downloading and installation, a special php file is used called Manage.php
Alberto Passalacqua
@AlbertoPa
thank you @samdark :-)
ArtemMaslyatnik
@ArtemMaslyatnik
Здравствуйте! При создании поста создать нового пользователя (сложную модель) в модальном окне и вернутся и соответственно выбрать
Negruzzi Cristian
@EndErr
is there a tutorial how to work with AuthClient for registration with social networks?
hosseinabdollahzadeh
@hosseinabdollahzadeh

Hi everyone
I think that one of the reasons for the lack of development of Yii framework community compared to the Laravel framework is that Yii framework is insular in the local languages of each country.
Now with the review I did:

Russian telegram group: about 2000 members
Indonesian telegram group: about 1500 members
Uzbekistan telegram group: about 500 members

But there is no any English telegram group for powerful Yii2 framework. Why? 😳😐🤔

in this reason, I created a telegram group for Yii2 in English, please join it:

https://t.me/yii_framework_in_english