Pages

2021年5月27日木曜日

[Flutter] flutter doctor で Android Studio が入っているのに認識してくれない時

Android Studio をインストールしてるのに

> flutter doctor

で確認すると

[!] Android Studio (not installed)

となる。。

そんな時は

 > flutter config --android-studio-dir="C:\Program Files\Android\Android Studio"

とインストール場所を教えてやると解決!!

[√] Android Studio



2021年5月22日土曜日

[CakePHP4] 翻訳ファイルの作成まで

翻訳辞書ファイル(.po)を作成するまでの手順

PS D:\prj\example.com\www.example.com> ./bin/cake i18n
I18n Shell
-------------------------------------------------------------------------------
[E]xtract POT file from sources
[I]nitialize a language from POT file
[H]elp
[Q]uit
What would you like to do? (E/I/H/Q)
> E
Current paths: None
What is the path you would like to extract?
[Q]uit [D]one
[D:\prj\example.com\www.example.com\src\] >

Current paths: D:\prj\example.com\www.example.com\src\
What is the path you would like to extract?
[Q]uit [D]one
[D:\prj\example.com\www.example.com\templates\] >

Current paths: D:\prj\example.com\www.example.com\src\, D:\prj\example.com\www.example.com\templates\
What is the path you would like to extract?
[Q]uit [D]one
[D] >

Would you like to extract the messages from the CakePHP core? (y/n)
[n] > y
What is the path you would like to output?
[Q]uit
[D:\prj\example.com\www.example.com\resources\locales\] >


Extracting...
-------------------------------------------------------------------------------
Paths:
   D:\prj\example.com\www.example.com\src\
   D:\prj\example.com\www.example.com\templates\
   D:\prj\example.com\www.example.com\vendor\cakephp\cakephp\src\
Output Directory: D:\prj\example.com\www.example.com\resources\locales\
-------------------------------------------------------------------------------
==========================================================================> 100%
default.pot is unchanged. Skipping.
cake.pot is unchanged. Skipping.

Done.

ここまでで .po ファイルの雛形となる .pot ファイルが作成される。

What would you like to do? (E/I/H/Q)
> I
Please specify language code, e.g. `en`, `eng`, `en_US` etc.
> ja_JP
What folder?
[D:\prj\example.com\www.example.com\resources\locales\] >

.po が ja_JP 以下に作成される。

2021年5月18日火曜日

[CakePHP4] bake template で index,view,add,edit 以外を追加

自分は
  • add.php
  • edit.php
  • index.php
  • view.php
以外にも form.php を作成していて、 add.php, edit.php からそれを呼び出して共通かしています。
なので、bakeコマンドで form.php も作ってほしい。

あと基本的には Bootstrap を利用しているので、テーマを自作してと。。
  • plugins/BootstrapTheme/templates/bake/Template/add.twig
  • plugins/BootstrapTheme/templates/bake/Template/edit.twig
  • plugins/BootstrapTheme/templates/bake/Template/index.twig
  • plugins/BootstrapTheme/templates/bake/Template/view.twig
  • plugins/BootstrapTheme/templates/bake/Template/form.twig
こんな感じ。

作成して 

$ ./bin/cake bake template

とするけど。。

いつも通り
  • add.php
  • edit.php
  • index.php
  • view.php
ができるだけ。。

form.php だけを追加するのは以下のようなコマンドでできるので、自分のそれで追加しています。。

$ ./bin/cake bake template samples form


2019年12月26日木曜日

[PHP] Amazon MWS API Feed のXMLをXSDファイルを利用してバリデート(検証)する

gontoraさんによる写真ACからの写真

Amazon MWS API を利用して出品する際にXMLで一覧を生成するのだが、その生成したXMLが正しいかを判別するために Amazon MWS API のドキュメントサイトで配布されている XSD を利用した。

http://docs.developer.amazonservices.com/ja_JP/feeds/Feeds_FeedType.html

注: XMLフィードの作成方法によっては、商品情報フィードではなく、アイテムフィードスキーマを使用するよう、出品者に求められます。

ほんまAmazon紛らわしいな。。
こんな紛らわしいのに開発環境提供してくれないし。。。

Item フィード
https://images-na.ssl-images-amazon.com/images/G/01/rainier/help/xsd/release_1_9/Item.xsd

Product フィード
https://images-na.ssl-images-amazon.com/images/G/01/rainier/help/xsd/release_1_9/Product.xsd

XSDを利用してのXML検証方法


$xml = new DOMDocument(); 
libxml_use_internal_errors(true);

$xml->load('./sample.xml');
 
if ($xml->schemaValidate('./validate.xsd')) { 
   echo "Success \n";
} 
else { 
    echo "Error \n"; 
    $errors = libxml_get_errors();
    foreach ($errors as $error) {
        echo display_xml_error($error, $xml);
    }
    libxml_clear_errors();
} 

function display_xml_error($error, $xml)
{
    $return  = $xml[$error->line - 1] . "\n";

    switch ($error->level) {
        case LIBXML_ERR_WARNING:
            $return .= "Warning $error->code: ";
            break;
         case LIBXML_ERR_ERROR:
            $return .= "Error $error->code: ";
            break;
        case LIBXML_ERR_FATAL:
            $return .= "Fatal Error $error->code: ";
            break;
    }

    $return .= trim($error->message) .
               "\n  Line: $error->line" .
               "\n  Column: $error->column";

    if ($error->file) {
        $return .= "\n  File: $error->file";
    }
}

2019年11月20日水曜日

composer 削除方法

$ composer remove --no-update phpoffice/phpexcel
$ composer update --dry-run

Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 0 updates, 1 removal
  - Uninstalling phpoffice/phpexcel (1.8.2)

- Uninstalling *** をアップデートで削除

$ composer update phpoffice/phpexcel

複数該当する場合

Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 0 updates, 1 removal
  - Uninstalling phpoffice/phpexcel (1.8.2)
  - Uninstalling phpoffice/hoge (1.8.2)
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.

$ composer update phpoffice/phpexcel phpoffice/hoge

Followers