tokisabaのブログ

エンジニア系シェアハウスEngineMakerの管理人ブログ

composer updateでエラーが出たけど解決したので貼っとく

検索したけど、結局PHPのバージョンが古くなってるだけだった。 5.x系だとダメで7.x系なら動いたので入れた…というか入ってたはずなのに消えてた…orz

検索しづらかったので、ログ貼って検索しやすくしとく


$ composer update Loading composer repositories with package information Updating dependencies (including require-dev) Nothing to install or update Generating autoload files

Incenteev\ParameterHandler\ScriptHandler::buildParameters Updating the "app/config/parameters.yml" file Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache

In Configuration.php line 69:

Warning: date_default_timezone_get(): It is not safe to rely on the system'
s timezone settings. You are required to use the date.timezone setting or
the date_default_timezone_set() function. In case you used any of those me
thods and you are still getting this warning, you most likely misspelled th
e timezone identifier. We selected the timezone 'UTC' for now, but please s
et date.timezone to select your timezone.

Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the symfony-scripts event terminated with an

[RuntimeException]
error when the "'cache:clear --no-warmup'" command:

In Configuration.php line 69:
Warning: date_default_timezone_get(): It is not safe to rely on the system's
timezone settings. You are required to use the date.timezone setting or
the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the
timezone identifier. We selected the timezone 'UTC' for now, but please
set date.timezone to select your timezone.

PHP:Symfony3:Doctrine:createNativeQuery:in句 の利用についてざっくり

ORMなんて嫌いだー。

とりあえず、複雑なSQLと仮定して、ナマでSQLを叩きたくなったら以下のような感じでいける。 ここらへん資料少くて辛い。誰かの役に立てば幸い。

    $entityManager = $this->getDoctrine()->getManager();
    $idlist= array();

    for($i=0;$i<count($hogeList);$i++){
        $idList[] = $hogeList[$i]; // in句で渡したい配列を入れる
   }

    $sql = "select hoge1,hoge2
              from foo_table
              where var_clm in (:idList);";

    $rsm = new ResultSetMapping();
    $rsm->addScalarResult('hoge1', 'hogehoge'); // 結果セットのカラムのマッピング必須
    $rsm->addScalarResult('hoge2', 'hogehage'); // 結果セットのカラムのマッピング必須(無いとselectに書いてても取得されない)
    $query = $entityManager->createNativeQuery($sql,$rsm)
    $query->setParameter("idList", $idList, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY); //配列を引数に渡す
    $data = $query->getResult();

PHPStormでソースコードが消える問題について

PHPStormでローカル編集したものを、PHPStormのDeploy機能でvagrantにファイルを送ってる or vagrantのsyncで送ってる。

だいたいは問題ないのだけど、たまに問題があって、何故かソースが消える。 編集画面ひらいたままだと、編集画面のソースが消える。ファイル自体は0バイトで残っている。

いろいろ調べたりぐぐってみたけど、同様の現象の人もいないようで結構困ってる…。 ということで、誰か同様の現象がでてここにたどり着いた人は、コメントに「俺も!」とかだけでもいいので書いておいてくれるとありがたい…。

追記:解決した

VagrantFileの中でconfig.vm.synced_folderを設定していると、フォルダが同期してコピーされてる…ではなくmountされてる状態になっているので、PHPStormからdeploy機能でファイル転送しようとすると、同じフォルダから同じフォルダに書き込む状態になるので、そこで一旦ファイルがゼロになってしまうぽい。

わかってから調べるとちゃんとした資料にもいきやすいな…。 syncedとか言ってるからrsync的なものだと思ってた…orz

tech.respect-pal.jp

PHPStormでPush failed: Failed with error: Could not read from remote repository.

Pushすると

Push failed: Failed with error: Could not read from remote repository.

とか言われる。

settings-->Version Control-->Git  の SSH executable で Native を選択する。選択済みなら一度別のを選んで適用してから、もう一度選んで適用。

それでもダメなら

VCS -> Git -> Remotes.

で、URLを設定しなおしたら治った。

PHP:S3で取得したデータをImageMagickで処理する

取得した時にBodyに入ってるデータがblob形式なので、それにあわせて処理する。

$s3 = S3Client::factory($auth);
$s3_result = $s3->getObject([
    'Bucket' => $bucket,
    'Key' => $key,
]);
$image = new \Imagick();

//Now I can read a binary file
$image->readImageBlob($s3_result['Body']);
$image->adaptiveResizeImage(150, 150, true);

PHPでAWSのSQSメッセージを処理する

受け取ったメッセージの処理ではまったのでメモ。

// メッセージを受け取る
$result = $sqs->receiveMessage(array(
    'QueueUrl' => $queueUrl['QueueUrl'],
));

// Messagesを取得
$data = $result->get('Messages');

// null対策
if($data){
    foreach($data as $item){
        // Messagesの中身を取得
        $res2 = json_decode($item['Body'], true);
        // さらにその中身を取得
        $res3 = json_decode($res2['Message'], true);
    }
}

で、ようやくキレイにデータがとれた。

S3→SNS→SQS やろうとしたらS3 Event設定ではまったのでメモ

イベント設定しようとしたら

The notification destination service region is not valid for the bucket location constraint

でハマる。ロケーションおかしいとか言われてもそもそもS3はコンソール画面右上にも

f:id:tokisaba:20180323133021p:plain

って書かれてるし、???と思ってたら見落としてた。バケット一覧でリージョンちゃんと書いてる…

f:id:tokisaba:20180323133031p:plain

SNSで使ってるリージョンと合わせたら治った。

処理順的には

  • SNSでトピックを作る
  • SQSでキューを作る
    • 側からSNSに紐付ける(SNS側からもできるけど、設定がこちらのほうが簡単)
  • S3でバケットを作る
    • S3側からSNSにイベント設定する