免責聲明

Disclaimer (免責聲明)
繼續閱覽代表您接受以上的免責聲明.
To continue reading means you accept the above disclaimer.

2014年4月29日 星期二

php + iis + win8

最近(2014.04) 試著在windows 8上 跑dropBox php sdk 的 sample code,
至少得有php 才行. 到php.net 下載 php5.4的zip檔, 該選 thread-safe 還是 non-thread-safe ?
應該是safe比較安全吧 ? 小心駛得萬年船?  -->  莫非 non-thread-safe 才對 ? [***]

解壓縮之後, 將php.exe的目錄加入環境變數的Path裡,

在命令列(command line, command prompt)執行
php ./examples/authorize.php  ...
php .examples/account-info.php ...
都 OK,

But

php ./examples/web-file-browser.php  ...
試了好幾次都不行 ...

只好回頭來檢查 iis 與 php 的設定,
多次參拜google 大神後, 終於發現指示 :

//===
0. 比較新也比較方便的做法就是先安裝Web Platform Installer(WebPI),
1. 執行WebPI , search php, 找到最近的php5.4.24, 按下Add,
    WebPI的左下角會顯示所選擇的套件數目 ...

2. WebPI 自動將php 安裝於
    C:\Program Files (x86)\iis express\PHP\v5.4   , 並加入 Path
    所以得將之前手動安奘所加的路徑移除 避免打架

3. 於C:\inetpub\wwwroot 建立 info.php 測試網頁
    <?php phpinfo(); ?>

4. http://localhost/info.php ... 又失敗!!!
    看看錯誤訊息 :  iis 尚未加入php 的handler. 根據 [2] 還需要加入 module mapping:

Admin Tools -> IIS manager  ->  雙擊(double click) "Handler mappings"
-> 右邊panel 上方 點選Add Module Mapping ...

//=== add module mapping
Request path: *.php
Module: FastCGImodule
Executable: C:\Program Files(x86)\php\v5.4\php-cgi.exe
Name: phpFastCgi

5. restart Default Web Site,  refresh http://localhost/info.php ,
   終於看到phpinfo()的結果了.

6. 其實還是可以手動安裝, 不過要自己去更改php.ini裡的諸多設定 [2][***]

[ref]
1.  http://support.microsoft.com/kb/2819022

2.  http://www.iis.net/learn/application-frameworks/install-and-configure-php-on-iis/install-and-configure-php

3. enable fastCGI
http://www.iis.net/learn/application-frameworks/install-and-configure-php-applications-on-iis/using-fastcgi-to-host-php


***
根據 [2] [3], 在Windows 上 應該下載 non-thread-safe (nts) 的版本, 檔案名稱中含有-nts-
[2][3] 都建議要用FastCGI 模式, 而非 ISAPI ...

2014年4月28日 星期一

Eclipse + Cannot create project content in workspace

一直沒搞清楚 Eclipse workspace 的觀念
在建立新的 project 時, 常會出問題 ...
今天想試試看DropBox 的 sdk examples,
又碰到 "Cannot create project content in workspace" 的錯誤訊息

上網搜尋找著似乎以前曾看過的文章, 還是讀不太懂 ,
不過終究歸納出解決之道:

0. project 不一定要放在workspace 的目錄下
1. 解壓縮後的sample code 先不要複製到 workspace 的目錄下

2. 建立新的project 時
簡單的方式就是先選
Create "new" project in workspace  [所以名字不能與workspace中既有的project或目錄名字相同]
之後再將解壓縮後的sample code 複製到該project的目錄下.

或者就在sample code 所在的目錄建立新project
Create new project at existing location(from existing source)
前提是1. sample code 所在的目錄不能先放在 workspace 的目錄下,
否則就會出現 "Cannot create project content in workspace" 的錯誤訊息


**** 我用的是 Eclipse Juno , 有好一陣子沒用, 也沒更新 ...

[ref]
http://stackoverflow.com/questions/9075849/cannot-create-project-content-in-workspace-when-trying-to-recreate-a-project

http://stackoverflow.com/questions/13552266/eclipse-workspaces-what-for-and-why

2014年4月15日 星期二

haxe tutorial+2, nme and flashdevelop

//=== 安裝好haxe之後
下載安裝 java sdk (1.6+?)
到flashdevelop.org 網站下載安裝 flashdevelop

http://www.flashdevelop.org/wikidocs/index.php?title=Installation
http://3hitek.blogspot.tw/2012/09/fd-flashdevelop-learning-1-debug-needs.html

於命令列安裝 nme
> haxelib install nme
> nme setup

*** 2014.04.15
haxe3 以後, nme 已轉成 openfl, 但openfl 與 nme 並不完全相容 ...
http://forum.haxepunk.com/index.php?topic=605.0
***

//== http://haxe.org/doc/start/cpp
nme uses .nmml file rather than hxml


"...
NME includes a custom build tool, mainly to handle the crossplatform assets management. The application isn't configured
using a .HXML file but with a .NMML config file, e.g.

sample.nmml :

<?xml version="1.0" encoding="utf-8"?>
<project>
  <app title="Displaying A Bitmap" main="DisplayingABitmap" package="org.haxenme.tutorial.displayingabitmap"
version="1.0.0" company="NME" />
 
  <window width="640" height="480" fps="30" orientation="portrait" resizable="true" />

  <set name="BUILD_DIR" value="Export" />
  <classpath name="Source" />
  <haxelib name="nme" />
  <assets path="Assets" rename="assets" include="*" exclude="nme.svg" />
  <ndll name="std" />
  <ndll name="regexp" />
  <ndll name="zlib" />
  <ndll name="nme" haxelib="nme" />
  <icon name="Assets/nme.svg" />
</project>
...
"

//=== 'nme' is a shortcut to 'haxelib run nme'

[nme usage samples]
nme test sample.nmml flash
nme test sample.nmml cpp
nme test sample.nmml android
nme test sample.nmml ios -simulator
nme update sample.nmml ios


haxe tutorial+1

下載/ 解壓縮/ 把檔案放到適當的目錄底下, 設定環境變數Path, ...

命令列用法:
  • haxe  -main <class>  -<target_platform> <output>  [option]+  [<input>]+
  • haxe  <hxml_file.hxml>  [option]+
[ ] 中括號裡的參數 可以省略
[ ]+ 表示可以不只一個
[<input>]+  就表示輸入的檔案可以不只一個(以空白隔開?)


-<target_platform> 支援的平台有 Flash, JavaScript, C++, PHP, Android?, Java?, ...
-swf
-js
-cpp
-php
-


[例1]
//=== 主類別 Client.hx, 輸出flash檔案 index.swf
haxe -main Client -swf index.swf

//=== 主類別 Server.hx 輸出neko檔案 server.n
haxe -main Server -neko server.n


//=== 將以上兩件工作放入 build.hxml  檔案中
#some comment
-main Client
-swf client.swf
--next
-main Server
-neko server.n
//=== 命令列
haxe build.hxml


[例2] 主類別Main.hx, 用到nme lib, tween lib
haxe -main Main -swf op1.swf -lib nme -lib tween


[ref]
http://haxe.org/doc/compiler