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

การตั้งค่าให้ใช้ 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.



ความคิดเห็น

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

การตั้งค่า 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...

การลบ public ใน codeigniter 4

Codeigniter 4 จะมี folder public โผล่มา เพื่อให้เราใช้งานในเวอร์ชั่น development ( เวอร์ชั่นที่อยู่ในขั้นตอนการพัฒนา ยังไม่ได้เปิดใช้งานจริง ) และเมื่อนำโปรเจคไปใช้งานจริง เราอาจจะไม่ต้องการให้ชื่อโฟลเด้อ public แสดงบน url วิธี ลบโฟลเด้อ public ออกจาก url สามารถทำได้ง่าย ๆ ใน 3 ขั้นตอน ง่ายๆ ดังนี้ ในโฟลเด้อ public ให้ย้าย ไฟล์ index.php, .htaccess และ robot.txt ออกมาไว้ที่ root ของโปรเจค จากนั้นลบ folder public ทิ้งได้เลย เปิดไฟล์ index.php จากนั้นให้แก้ไขตัวแปร FCPATH ให้พาธถูกต้อง จากเดิม (บรรทัดที่ 34) require FCPATH . ' ../app/Config/Paths.php ' ; แก้ไขเป็น require FCPATH . ' app/Config/Paths.php ' เปิดไฟล์ spark จากนั้นให้แก้ไขตัวแปร pathsPath ให้พาธถูกต้อง (หากเราไม่ทำการเปลี่ยนเราจะใช้ spark ไม่ได้เลย) จากเดิม (บรรทัดที่ 69) define ( 'FCPATH' , __DIR__ . DIRECTORY_SEPARATOR .'public'.DIRCTORY_SEPARATOR ); // Load our paths config file // This is the line that might need to be changed, depending on your folder structure. require FCPATH . ...

การติดตั้ง 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 . นอกจากนี้, ยังมีขั้นตอนอื่น ๆ ที่...