Environment Setup
- MySQL 5.7
- Maven 3.3.9
- Sencha Cmd & ExtJS
參考 : https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-centos-7
# 下載 MySQL package wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm rpm -ivh mysql57-community-release-el7-9.noarch.rpm # 安裝 MySQL yum install mysql-server # Start systemctl start mysqld # Status systemctl status mysqld # MySQL 預設是開機自動啟動的,如果不想要開機啟動的話,下指令 systemctl disable mysqld
第一次安裝完之後,會有一個預設密碼
grep 'temporary password' /var/log/mysqld.log
2016-12-01T00:22:31.416107Z 1 [Note] A temporary password is generated for root@localhost: mqRfBU_3Xk>r
想要改密碼的話,下指令
mysql_secure_installation (Enter a new 12-character password that contains at least one uppercase letter, one lowercase letter, one number and one special character. Re-enter it when prompted.) # 這有點麻煩,總之我就先設了12位數字的密碼,然後再手動修改 password policy level mysql -u root -p mysql> SHOW VARIABLES LIKE 'validate_password%'
+--------------------------------------+--------+ | Variable_name | Value | +--------------------------------------+--------+ | validate_password_dictionary_file | | | validate_password_length | 8 | | validate_password_mixed_case_count | 1 | | validate_password_number_count | 1 | | validate_password_policy | MEDIUM | | validate_password_special_char_count | 1 | +--------------------------------------+--------+ 6 rows in set (0.01 sec)
# The default level is MEDIUM, change it to LOW mysql> SET GLOBAL validate_password_policy=LOW; # 再跑一次 mysql_secure_installation 就可以改簡單一點的密碼了
2. Install Maven 3.3.9
Apache Maven : https://maven.apache.org/
MVN Repository : https://mvnrepository.com/
Maven 很強大,剛開始接觸時對於 pom.xml 也是很抗拒
實際使用後,真的是太好用了
# The default level is MEDIUM, change it to LOW # 下載 wget http://www.eu.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz # 解壓縮 tar -xf apache-maven-3.3.9-bin.tar.gz # 放到 /opt 目錄,需要 root 權限 # mv apache-maven-3.3.9 /opt/maven # ln -s /opt/maven/bin/mvn /usr/bin/mvn # Check mvn -v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00) Maven home: /opt/maven Java version: 1.8.0_121, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el7_3.x86_64/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "3.10.0-514.10.2.el7.x86_64", arch: "amd64", family: "unix"
預設的下載目錄在 ~/.m2/repository/
當發生 dependency 問題,最終可以考慮清空 m2/repository
也許就可以編過了
3. Install Sencha Cmd 6.6.2
不得不說,我對於 Sencha 非常有意見IDE 常當機、ExtJS 太肥、編 code 太久、多人協作時非常容易出問題
Download page : https://www.sencha.com/products/sencha-cmd/
下載 Linux 64 bit,約 66.6 MB
wget http://cdn.sencha.com/cmd/6.2.2/no-jre/SenchaCmd-6.2.2-linux-amd64.sh.zip unzip SenchaCmd-6.2.2-linux-amd64.sh.zip ./SenchaCmd-6.2.2.36-linux-amd64.sh
支援 GUI 以及 Terminal mode 安裝
預設會安裝在使用者 Home 目錄中
如果選擇Yes,它會加入到bashrc中
常用的話就加入吧…
4. 建立 Sencha ExtJS 專案
純粹練習與筆記
目前官網只提供EXTJS 6,公司是用EXTJS 5 (GG)
幸好有好心人提供載點下載
Github : https://github.com/bjornharrtell/extjs
git clone https://github.com/bjornharrtell/extjs mv extjs /opt/extjs # Start with generating a new workspace sencha generate workspace test_project/sencha
# tree . ├── packages └── workspace.json 1 directory, 1 file
cd sencha sencha -sdk /opt/extjs/ generate app MyApp MyApp
tree -L 2 . ├── build │ ├── development │ └── temp ├── ext │ ├── build │ ├── build.xml │ ├── classic │ ├── cmd │ ├── ext-bootstrap.js │ ├── licenses │ ├── modern │ ├── package.json │ ├── packages │ ├── resources │ ├── sass │ └── version.properties ├── MyApp │ ├── app │ ├── app.js │ ├── app.json │ ├── bootstrap.css │ ├── bootstrap.js │ ├── build.xml │ ├── classic │ ├── classic.json │ ├── classic.jsonp │ ├── index.html │ ├── modern │ ├── modern.json │ ├── modern.jsonp │ ├── overrides │ ├── Readme.md │ ├── resources │ └── sass ├── packages └── workspace.json 20 directories, 16 files
cd MyApp sencha app watch
打開Browser,輸入http://localhost:1841/MyApp/
常用指令:
- 建立 Workspace
- sencha generate workspace [workspace name]
- 建立 APP
- sencha -sdk [SDK Path] generate app [APP name] [APP Path]
- 由於 ext folder 不上 Git,所以在編譯前要先產生 ext folder
- 原本使用 sencha app upgrade [SDK Path],但某些時候會產生出 ext62 folder,導致編譯失敗
- 改用 sencha framework upgrade ext [SDK Path]
- 產生 View, controller and model
- sencha generate view [MyApp.MyView],等同于 app/view/MyApp/MyView.js
- sencha generate model [Model name] id:int,name:string,email:string
- sencha generate controller [Controller name]
- 編譯
- sencha app build
Online Editor : https://fiddle.sencha.com/
沒有留言:
張貼留言