2014年5月5日

PHP Framework 該如何選



對於一個寫了很久PHP的人來說

都會想找尋更好的方法

在五六年前,PHP Framework還不盛行的時候

只能由自己硬幹出很多的class 來resue

但在這個Framework爆炸的時代

就別再這麼辛苦了



Framework的選擇



其實還是要以自己的需求為主

像我這麼懶惰的人

就是不希望寫太多code

就能做到很多事

這時候就只能朝Full-stack的framework來選

例如像是:Symfony2, Laravel, Yii等

這一類的framework的優點是

套件多,功能多,包裝多,有一定的規範

在團隊合作時不會因為A喜歡這樣寫B喜歡那樣寫

整份project就充斥著不同的風格與寫法

但是有些人因為喜歡PHP的自由風氣

所以不想被這麼多規範給框住

或是只是想寫個留言板而已

幹嘛大費周章用這麼肥大的Full-stack framework?

這時就會想選輕量化的framework

像是CodeIgniter, Silex, Slim


framework 並沒有一定的好跟壞

全看自己的需求與想法來決定

如果要功能齊全,寫起來舒服覺得爽

被改需求也不會感到痛苦

並且想快速推出產品的話

Full-stack framework絕對是首選

如果要風格自由,要比較快

輕量化framework就是首選了

不過以現今趨勢來說

都是以Full-stack framework在猛烈成長

像是參考 Best PHP Frameworks for 2014 這篇文章來說

前幾名的都是Full-stack framework

還有很紅的Ruby on Rails也是

這似乎是一個趨勢啊

(大概大家都很懶的關係XDD)

2014年5月2日

CentOS SSH 時無法使用 su 換成root

今天突然無法用su -切換成root

以為被入侵入改了密碼

大老遠跑來server旁邊

竟然可以在local端登入

最後檢查/bin/su權限

發現是

-rwxr-xr-x.

才發現權限不對

估計是昨晚不知下了哪個指令給改了....

之後下

chmod u+s /bin/su

給改了回去

才正常。

2014年5月1日

讓SELinux可以透過httpd(PHP)寄信

SELinux開啟時

預設是無法直接由網站寄信的

可以先查看設定值


getsebool httpd_can_sendmail

一開始都是 off

然後

setsebool -P httpd_can_sendmail 1

和

chcon -t httpd_sys_content_t /usr/sbin/sendmail.postfix 

就可以透過網站(PHP)送信了

必要時可檢查與恢復postfix相關權限

# /etc/init.d/postfix stop
# chgrp postdrop /usr/sbin/postqueue
# chgrp postdrop /usr/sbin/postdrop
# chmod g+s /usr/sbin/postqueue
# chmod g+s /usr/sbin/postdrop
# /etc/init.d/postfix start

2013年9月18日

Symfony2 initial project ICU problem

今天在初始化Symfony2時

在Terminal下

$php composer.phar instal

卻出現一串錯誤

Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for symfony/icu v1.2.0 -> satisfiable by symfony/icu[v1.2.0].
    - symfony/icu v1.2.0 requires lib-icu >=4.4 -> the requested linked library icu has the wrong version installed or is missing from your system, make sure to have the extension providing it.
  Problem 2
    - symfony/icu v1.2.0 requires lib-icu >=4.4 -> the requested linked library icu has the wrong version installed or is missing from your system, make sure to have the extension providing it.
    - symfony/symfony v2.3.4 requires symfony/icu ~1.0 -> satisfiable by symfony/icu[v1.2.0].
    - Installation request for symfony/symfony v2.3.4 -> satisfiable by symfony/symfony[v2.3.4].

最後弄很久

選擇怒關ICU功能

$php composer.phar require symfony/icu ~1.0

之後就正常了

2012年12月6日

How to hide the Apache version information in http header

edit the /etc/httpd/conf/httpd.conf file ( in Ubuntu server is /etc/apache2/apache2.conf )

and add

ServerTokens ProductOnly
ServerSignature Off

or edit if the option exist.

ServerTokens options and results:


ServerTokens ProductOnly

result:
Server: Apache

ServerTokens Major

result:
Server: Apache/2

ServerTokens Minor

result:
Server: Apache/2.0

ServerTokens Minimal

result:
Server: Apache/2.0.55

ServerTokens OS

result:
Server: Apache/2.0.55 (Debian)

ServerTokens Full (or not specified) default

result:
Server: Apache/2.0.55 (Debian) PHP/5.1.2-1+b1 mod_ssl/2.0.55 OpenSSL/0.9.8b


and hide the php information

edit /etc/php.ini

edit expose_php to Off

( expose_php = Off )

2012年11月16日

Amazon RedHat Instance ssh login


ssh -i /your/pem/path/file.pem root@ec2-xxxxx-1.ap-northeast-1.compute.amazonaws.com

use root...not ec2-user

>_<

2012年5月16日

HTC - 三星 - 蘋果




其實我完全不知道標題該怎麼下...

在此分享一篇文章

鴻海、宏達電  誰對台灣更重要?
http://www.cw.com.tw/article/article.action?id=5032848

我對財經是完全的門外漢
所以無法求證或給大家保證裡面數字都是對的
但商業週刊裡的文章應該不會離譜到哪

如果裡面所言屬實
我們是否該思考一下
買三星、蘋果的手機
會造成什麼樣的後果?

原本我也是半信半疑,愛用國貨有差這麼多嗎?
哪可能因為我一個人不買,明天台灣就垮掉了
但從這些現象看起來
還真的有可能...

撇開政治因素
HTC也為台灣帶來不少好處(這樣講應該對吧?肚子裡沒裝太多專有名詞XDD)
如果繼續助長三星、蘋果的勢氣
那真的只能說
『歡喜做,甘願受』
別怪薪水只有22k,也別怪薪水20年沒漲了....


我也不是在強迫大家要買哪家的產品
相信蘋果、三星這兩家廠商有各自的優點
才會吸引大批"粉絲"擁戴
這絕對是我們該學習的
但是選擇的當下
應該可以有另一種不一樣的思維來看待這件事!