ข้ามไปที่เนื้อหาหลัก

การตั้งค่าให้ใช้ Spark Ci4 ได้ภายใน server ของ Synology NAS

 หากท่านเข้า terminal ของ vs code แล้วเกิดอาการแสดง error ให้ท่านดำเนินการดังนี้
ตัวอย่าง error

php spark

Fatal error: Uncaught InvalidArgumentException: The .env file is not readable: \\YOUR_SERVER\WEB\esign-approve\.env in \\YOUR_SERVER\WEB\(ชื่อโปรเจคของท่าน)\vendor\codeigniter4\framework\system\Config\DotEnv.php on line 62

InvalidArgumentException: The .env file is not readable: \\\\YOUR_SERVER\WEB\(ชื่อโปรเจคของท่าน)\.env in \\\\YOUR_SERVER\WEB\(ชื่อโปรเจคของท่าน)\vendor\codeigniter4\framework\system\Config\DotEnv.php on line 62

Call Stack:

    0.0354     413520   1. {main}() \\\\YOUR_SERVER\WEB\(ชื่อโปรเจคของท่าน)\spark:0

    4.1167    2077848   2. CodeIgniter\Config\DotEnv->load() \\\\YOUR_SERVER\WEB\(ชื่อโปรเจคของท่าน)\spark:79

    4.1167    2077848   3. CodeIgniter\Config\DotEnv->parse() \\\\YOUR_SERVER\WEB\(ชื่อโปรเจคของท่าน)\vendor\codeigniter4\framework\system\Config\DotEnv.php:45


1. เข้าไปที่ตัวจัดการไฟล์


2. เลือก folder ของท่าน ที่ท่านกำลังดำเนินการอยู่
ตัวอย่าง


      2.1 คลิกขวา เลือก คุณสมบัติ


      2.2 เมื่อดำเนินการคลิกเรียบร้อยแล้ว ให้ท่านดำเนินการ ให้สิทธิ์การเข้าถึงไฟล์ ของ Everyone ทุกอย่าง


เมื่อดำเนินการเรียบร้อย ให้ท่านทดสอบ vs code ด้วยคำสั่ง php spark

ผลเป็นดังนี้
PS Microsoft.PowerShell.Core\FileSystem::YOUR_SERVER\WEB\(ชื่อโปรเจคของท่าน)> php spark

CodeIgniter v4.4.3 Command Line Tool - Server Time: 2023-11-28 08:38:44 UTC+07:00

Cache
'YOUR_SERVER\WEB\(ชื่อโปรเจคของท่าน)'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
  cache:clear        Clears the current system caches.
  cache:info         Shows file cache information in the current system.

CodeIgniter
  env                Retrieves the current environment, or set a new one.
  filter:check       Check filters for a route.
  help               Displays basic usage information.
  list               Lists the available commands.
  namespaces         Verifies your namespaces are setup correctly.
  publish            Discovers and executes all predefined Publisher classes.
  routes             Displays all routes.
  serve              Launches the CodeIgniter PHP-Development Server.

Database
  db:create          Create a new database schema.
  db:seed            Runs the specified seeder to populate known data into the database.
  db:table           Retrieves information on the selected table.
  migrate            Locates and runs all new migrations against the database.
  migrate:refresh    Does a rollback followed by a latest to refresh the current state of the database.
  migrate:rollback   Runs the "down" method for all migrations in the last batch.
  migrate:status     Displays a list of all migrations and whether they've been run or not.

Encryption
  key:generate       Generates a new encryption key and writes it in an `.env` file.

Generators
  make:cell          Generates a new Cell file and its view.
  make:command       Generates a new spark command.
  make:config        Generates a new config file.
  make:controller    Generates a new controller file.
  make:entity        Generates a new entity file.
  make:filter        Generates a new filter file.
  make:migration     Generates a new migration file.
  make:model         Generates a new model file.
  make:scaffold      Generates a complete set of scaffold files.
  make:seeder        Generates a new seeder file.
  make:validation    Generates a new validation file.
  migrate:create     [DEPRECATED] Creates a new migration file. Please use "make:migration" instead.
  session:migration  [DEPRECATED] Generates the migration file for database sessions, Please use  "make:migration --session"
                     instead.

Housekeeping
  debugbar:clear     Clears all debugbar JSON files.
  logs:clear         Clears all log files.



ความคิดเห็น

โพสต์ยอดนิยมจากบล็อกนี้

การติดตั้ง CodeIgniter 4 (CI4) ด้วย Composer

  การติดตั้ง CodeIgniter 4 (CI4) ด้วย Composer มีขั้นตอนหลัก ๆ ดังนี้: ติดตั้ง Composer: ถ้าคุณยังไม่มี Composer ติดตั้งในระบบของคุณ คุณต้องติดตั้ง Composer จาก getcomposer.org . สร้างโปรเจ็กต์ CodeIgniter 4: เปิดโปรแกรมเทอร์มินัลหรือ Command Prompt แล้วใช้คำสั่งต่อไปนี้: composer create-project codeigniter4/appstarter myproject แทน "myproject" ด้วยชื่อโปรเจ็กต์ที่คุณต้องการ. เข้าสู่โปรเจ็กต์: ในที่ที่คุณสร้างโปรเจ็กต์, เข้าไปที่ไดเรกทอรีโปรเจ็กต์: cd myproject รันเซิร์ฟเวอร์ในโหมดพัฒนา: เพื่อทดสอบโปรเจ็กต์ของคุณ, คุณสามารถรันเซิร์ฟเวอร์ในโหมดพัฒนา: php spark serve นอกจากนี้, คุณสามารถใช้เซิร์ฟเวอร์ที่ให้คุณควบคุม, เช่น Apache, Nginx, หรือ PHP Built-in Server. เข้าระบบ CI4: เปิดเว็บบราวเซอร์และเข้าไปที่ http://localhost:8080 (หรือที่กำหนดไว้ในกรณีที่ใช้คำสั่ง php spark serve ) เพื่อดูหน้าจอต้อนรับของ CodeIgniter 4. นอกจากนี้, คำสั่ง composer create-project ยังสามารถให้คุณกำหนดเวอร์ชันของ CodeIgniter 4 ที่คุณต้องการติดตั้ง. ตัวอย่าง: composer create-project codeigniter4/ap...

การติดตั้ง CodeIgniter 4 แบบ Download

  การติดตั้ง CodeIgniter 4 มีขั้นตอนหลายขั้นตอนที่ควรทำตามดังนี้: ดาวน์โหลด CodeIgniter 4: คุณสามารถดาวน์โหลดได้จาก เว็บไซต์ CodeIgniter โดยเลือกเวอร์ชันที่คุณต้องการ. แตกไฟล์: หลังจากดาวน์โหลดไฟล์ zip ของ CodeIgniter 4 ให้แตกไฟล์ zip นั้น. เปลี่ยนชื่อไดเร็กทอรี: เปิดโฟลเดอร์ที่ได้จากการแตกไฟล์แล้ว และเปลี่ยนชื่อโฟลเดอร์เป็นชื่อโปรเจ็กต์ที่คุณต้องการ. ตั้งค่าฐานข้อมูล: ไปที่ไฟล์ .env ในโฟลเดอร์ของโปรเจ็กต์ของคุณ. ตั้งค่ารายละเอียดของฐานข้อมูล เช่น database.default.hostname , database.default.database , database.default.username , และ database.default.password . สร้างตารางฐานข้อมูล: ใน CLI (Command Line Interface) ของระบบคอมพิวเตอร์, เข้าไปในโฟลเดอร์ของโปรเจ็กต์ของคุณแล้วรันคำสั่ง: php spark migrate สร้าง Controller และ View: ใน CLI, รันคำสั่งเพื่อสร้าง Controller และ View ตัวอย่าง: php spark make :controller MyController php spark make :view my_view ทดสอบ: เปิดเว็บบราวเซอร์และเข้าไปที่ URL ของโปรเจ็กต์ของคุณ เช่น http://localhost/myproject . นอกจากนี้, ยังมีขั้นตอนอื่น ๆ ที่...

การตั้งค่า baseController

  <?php namespace App\Controllers ; use CodeIgniter\ Controller ; use CodeIgniter\HTTP\ CLIRequest ; use CodeIgniter\HTTP\ IncomingRequest ; use CodeIgniter\HTTP\ RequestInterface ; use CodeIgniter\HTTP\ ResponseInterface ; use Psr\Log\ LoggerInterface ; /**  * Class BaseController  *  * BaseController provides a convenient place for loading components  * and performing functions that are needed by all your controllers.  * Extend this class in any new controllers:  *     class Home extends BaseController  *  * For security be sure to declare any new methods as protected or private.  */ abstract class BaseController extends Controller {     /**      * Instance of the main Request object.      *      * @var CLIRequest | IncomingRequest      */     protected $request ;     /**      * An array of helpers to be lo...