Software Engineer Blog

エンジニアブログです。技術情報(Go/TypeScript/k8s)や趣味の話も書くかもです。

Vagrantに開発環境構築

新規サービスの開発環境を整えるために、新たにnginx+php-fpm環境を構築しました。

参考のリンクまとめ

1.Vagrant構築

qiita.com

2.nginx構築

qiita.com

3.php-fpm構築

qiita.com

centOS7では、
nginxのスタートコマンドは
systemctl start nginx
自動起動コマンドは
systemctl enable nginx

php-fpmも同様に
systemctl start/enable php-fpm

また、開発ディレクトリを変更してPHPを動作させるには、/etc/nginx/conf.d/default.conf内の

 location / {
      root   /var/www;
      index  index.php;
}

と変更し、以下の部分も

location ~ \.php$ {
      root           /var/www;
      fastcgi_pass   127.0.0.1:9000;
      fastcgi_index  index.php;
      fastcgi_param  SCRIPT_FILENAME  /var/www$fastcgi_script_name;
      include        fastcgi_params;
    }

と変更することで、動きました。 書いてたら、Qiitaに書けよと言われそうな(もしくは、この記事いる?)記事になってました。

Alloyにて、別Viewのオブジェクトの取得方法

Viewは、Requireを利用してViewごとにファイルを分けて記述していたのですが、当該ControllerのViewではないViewの情報を引っ張ってきたい処理がしたかったので、やってみました。
めっちゃ簡単でした。正直、MVC慣れしていないのでまだ手探り状態です。

例えば、hoge Controller上にて、indexのを引っ張ってきたい場合

var tab = Alloy.createController("index").getView("tab1");

と書けばよいですね。
Controllerを経由して情報を引っ張ってくる ということが重要。

Appcelerator studioでのアプリ開発のTextFieldクリック時に、アプリが落ちる問題

weird bug after clicking on textField » Community Questions & Answers » Appcelerator Developer Center

上記を参考に、変更を加えました。 どうやら、TableViewの中身が何もないと、落ちてしまうようです。 なので、以下のように一行足してあげればOKです。

    $.table.setData([{"title": ""}]);

(実際のところ、この行邪魔になるけどなぁ)

laravel4.2プロジェクト作成

composer create-project laravel/laravel=~4.2 /vagrant/hoge --prefer-dist

でcreateすると、

 [RuntimeException]
  Failed to clone git@github.com:laravel/laravel.git via git, https,
  ssh protocols, aborting.
  - git://github.com/laravel/laravel.git
    Cloning into '/vagrant/green'...
    error: could not commit config file /vagrant/green/.git/config

このようなエラーが出ました。

composer create-project laravel/laravel=~4.2 hoge --prefer-dist

ディレクトリを真上にすると、うまくいきました。
原因は不明です。

Laravel 4 にてコントローラーを移動させた時のエラー処理

”コントローラーが見つけられません”というエラーに対して、

composer dump-autoload

または、

php artisan dump-autoload

をしてあげれば解決。

下記参考
Laravel4のオートロード
Laravel4、アップデートとトラブルシューティング

Existing lock /var/run/yum.pid の際

Existing lock /var/run/yum.pid: another copy is running as pid 14730.
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: yum

のエラーが出た際は、以下のコマンドでyum.pidを削除してしまえば良いみたい。

rm -f /var/run/yum.pid