Category Archive python

Byphunsanit

phpfmt : PHP 70 or newer is required.

จะใช้ php-fmt จัด code ให้ดูมีระเบียน แต่มันมีแมสแซสขึ้นมาว่า

Warning.
PHP 70 or newer is required.
Please, upgrade your local PHP installation.
Debug information:phpfmt (php version):
PHP 5.6.12 (cli) (built: Aug 6 2015 12:06:20)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.60, Copyright (c) 1998-2015 Zend Technologies

phpfmt (php tokenizer) found

ใจก็อยากจะเปลี่ยนเป็น php7 กับเค้าเหมือนกันแต่เป็นเพราะว่างานที่ทำอยู่ใช้ sql server เป็นฐานข้อมูล และมันยังไม่มี driver สำหรับ php 7 ให้ใช้ จึงต้องแก้ที่ปลายเหตุ เอา alert ตัวนี้ออกไปแทน หา config ของ phpfmt ไม่เจอเลยที่มีคน post ไว้ก็ใช้ไม่ได้ เลยต้องให้วิธีไป comment เอามันออกแทน

  1. ไปที่ Preferences > Browse Packages จะมี folder เปิดขึ้นมา ไปที่ phpfmt
  2. ใช้ sublime search หา PHP 7.0 or newer is required
  3. ไปเจอ 3 จุดแต่ดูแล้วน่าจะเป็นsublime.message_dialog(‘Warning.\nPHP 7.0 or newer is required.\nPlease, upgrade your local PHP installation.\nDebug information:’+s)
    return False
  4. เปิดขึ้นมาแล้ว comment เอามันออกไป plugin ตัวนี้เขียนกับ python การ comment ตาม syntax คือใช้ # หน้าบรรทัดที่ต้องการ
    # if (‘PHP 5.3’ in res.decode(‘utf-8’) or ‘PHP 5.3’ in err.decode(‘utf-8’) or ‘PHP 5.4’ in res.decode(‘utf-8’) or ‘PHP 5.4’ in err.decode(‘utf-8’) or ‘PHP 5.5’ in res.decode(‘utf-8’) or ‘PHP 5.5’ in err.decode(‘utf-8’) or ‘PHP 5.6’ in res.decode(‘utf-8’) or ‘PHP 5.6’ in err.decode(‘utf-8’)):
    # s = debugEnvironment(php_bin, formatter_path)
    # sublime.message_dialog(‘Warning.\nPHP 7.0 or newer is required.\nPlease, upgrade your local PHP installation.\nDebug information:’+s)
    # return False

ดูเพิ่มเติม จัด code php ตาม PHR 2

Byphunsanit

วิธีลง Python บน windows 7 / 8

ลงไพธอนใหม่ที่ไรเป็นจะต้องหาวิธีลงใหม่ทุกครั้ง เพราะว่าวิธีในคู่มือใช้กับ windows 7 / 8 ไม่ได้ เลยขอจดไว้กันลืม

  1. โหลด Python มาจากเว็บ ลงให้เรียบร้อย
  2. ไปที่ control panel (windows 8 กด win key + x ) > Control Panel > System and Security > System
  3. คลิก Advance system settings
  4. คลิกแท็ป Advance กดปุ่ม Environment Variables ด้านล่าง
  5. จะเห็นหน้าต่าง Environment Variables เปิดขึ้น
  6. กด New มา ใต้ System variables ในช่อง Variable name: ใส่ Path
    ช่อง Variable value ใส่ path ที่ลงโปรแกรมไว้เช่น C:Python27;C:Python27DLLs;C:Python27Lib;C:Python27Liblib-tk (ให้แทนที่ C:Python27 ด้วย path ที่ลง python ไว้)
  7. ทดสอบโดยเปิดหน้า command ชึ้นมาใหม่ พิมย์ echo %Path% ถ้าเห็น path ที่ใส่เข้าไปแสดงว่าใช้ได้