Category «Uncategorized»

Install silverstripe4 on mac via composer

composer create–project silverstripe/installer ./my/website/folder Got error: need to install php-intl Solution: change default php7.1 to php7.3 by vi ~/.bash_profile … export PATH=/usr/local/opt/[email protected]/bin:$PATH source ~/.bash_profile now, php -v shows php7.3 php -i | grep intl run composer create–project silverstripe/installer ./my/website/folder again and looks fine Go to http://localhost/install.php shows error says need to set timezone vi php.ini set date.timezone …

How to efficiently update/sync pivot table/join table using PHP with selected multiple checkbox

First, Let’s assume we pass selected multiple checkboxes ids to parameter permissionIds, eg. 4,5,2,12,9 $existsPageIdsAry = array_column($existsPermissions, ‘pageID’); $permissionIdsAry = explode(‘,’,$data[‘permissionIds’]); $pageIdsNeedRemove = array_diff($existsPageIdsAry, $permissionIdsAry); $pageIdsNeedAdd = array_diff($permissionIdsAry, $existsPageIdsAry); Then we can do delete where id in ($pageIdsNeedRemove) and insert pivot table records in $pageIdsNeedAdd

How to insert multiple record using Doctrine

/** * Insert multiple record together * improve speed from 8 seconds to less than 1 second for insert 200 records */ $em = $this->_service->getEntityManager(); foreach ($pageIdsNeedAdd as $pageID ){ $rp = newRolePermission; $rp->pageID = $pageID; $rp->roleID = $data[‘roleID’]; $em->persist($rp); } $em->flush(); $em->clear();

Google reCaptcha V2 & V3 javascript demo and php example code

<?php // google recaptcha v2 $siteKey = ‘siteKey222’; $secret = ‘secret2222’; // google recaptcha v3 $siteKey_v3 = ‘siteKey333’; $secret_v3 = ‘secret3333’; function getRrecaptchaResult($secret_key, $g_recaptcha_response) { $curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_URL => ‘https://www.google.com/recaptcha/api/siteverify’, CURLOPT_POSTFIELDS => [ ‘secret’ => $secret_key, ‘response’ => $g_recaptcha_response, ‘remoteip’ => $_SERVER[‘REMOTE_ADDR’] ] ]); $response = …

How to pkill file name with space or with command parameter string

How to pkill file name with space or with command parameter string # more mqtt_subscribe.sh pkill -9 -f “php artisan extraction:analyze”; cd /www/backend.extraction/extraction/laravel; sudo -u www-data php artisan extraction:analyze 3 > ./storage/logs/mqtt_sub.log & tail -f ./storage/logs/mqtt_sub.log; accordingly to the pkill man page: -f The pattern is normally only matched against the process name. When -f …

How to check the mac memory and cpu information

How to check the mac memory and cpu information? The following works in OS X Lion: $ /usr/sbin/system_profiler SPHardwareDataType Hardware: Hardware Overview: Model Name: iMac Model Identifier: iMac7,1 Processor Name: Intel Core 2 Duo Processor Speed: 2.4 GHz Number of Processors: 1 Total Number of Cores: 2 L2 Cache: 4 MB Memory: 4 GB Bus …