PHP ??: CodeIgniter? ???? MVC ?? ? RESTful API ??
Jun 16, 2023 am 08:09 AM? ??????? ?? ???? ?? ? ??? ????? ??????? ???? ?? ?????. ??? ? ???????? RESTful API? ?? ???? ?? ???? RESTful API? ???? ???? ??? ???? ?? ??????. ?? ???? CodeIgniter ?????? ???? MVC ??? RESTful API? ???? ??? ?? ?????.
MVC ?? ??
MVC(Model-View-Controller), ? ??-?-????? ???? ?????? ???? ???? ??? ?????. MVC ???? ??????? ? ???? ????.
Model(??) - ??? ? ??? ??? ???? ?????.
View - ??? ?????? ??? ??? ???? ?????.
Controller - ??? ???? ??? ??? ???? ?????.
MVC ????? ? ?????? ???? ?? ???? ?? ? ?????. ?? ?? ???? ??????? ?? ??? ???? ???? ??? ? ?? ? ? ????.
RESTful API ?? ??
?????? ??? ?? ??? REST(Representational State Transfer)? ? ???? ??? ?? ?????. RESTful API? ??? ?? ? ??? ?? HTTP ????? ???? ???? ??? ? ??????.
RESTful API ????? ???? ??? ??? ???? URI(Uniform Resource Identifier)? ?? ??????. ?????? HTTP ??(GET, POST, PUT, DELETE)? ???? ???? ?? ??? ??? ? ????. ?? ?? RESTful API? ???? ?? ?? ???? ???? ?? ? ?? ??? ?? ???? ????.
CodeIgniter Framework
CodeIgniter? ?? ? ??? ?? ?? PHP ?? ????????. ?? ???? ??? ? ??????? ???? ??? ? ?? ??? ?????? ??? ?? ? ?????? ??? ?? ??? ?????.
CodeIgniter? ???? MVC ?? ??
CodeIgniter ????? ??? MVC ??? ???? ???????. ?? ???? MVC ??? ???? ??? ???????.
- ?? ???
CodeIgniter?? Model ?? ??? ??? ? ??? ??? ???? ??????? ???? ??? ?????. application/models ????? ???? ?? ???? ??? ? ????.
??? ??? ?? ??? ????.
<?php class Users_model extends CI_Model { public function __construct() { $this->load->database(); } public function get_users() { $query = $this->db->get('users'); return $query->result_array(); } }
?? ? ??? users?? ???? ?? ???? ?????. $this->db->get() ???? ???? ???????? ???? ?????.
- View ???
CodeIgniter?? View ?? ??? ??? ????? ??? ???? ?? ??? application/views ????? ?????. ???? ?? ??? ?? ? ????.
??? ??? ?? ?? ????.
<html> <head> <title>Users List</title> </head> <body> <h1>Users List</h1> <table> <thead> <tr> <th>ID</th> <th>Name</th> </tr> </thead> <tbody> <?php foreach ($users as $item) { ?> <tr> <td><?php echo $item['id']; ?></td> <td><?php echo $item['name']; ?></td> </tr> <?php } ?> </tbody> </table> </body> </html>
?? ? ??? ??? ?? ?? $users? ???? ?????. foreach ??? ???? ???? ???? HTML ???? ??????.
- Controller ???
CodeIgniter?? Controller ?? ??? ??? ??? ???? ??? ?? ??? Model ? View ?? ??? ???? ??? ???. application/controllers ????? ???? ???? ???? ??? ? ????.
??? ??? ???? ??? ?????.
<?php class Users extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('users_model'); } public function index() { $data['users'] = $this->users_model->get_users(); $this->load->view('users', $data); } }
? ?? ???? ???? URL? ????? index ???? ?????. ? ???? Model ?? ???? ? ???? ???? ?? ?? ?? HTML ??? ??? ??? ?????.
CodeIgniter? ???? RESTful API ??
CodeIgniter??? RESTful API? ???? ? ???? ?? ?? ? ????. CodeIgniter? ???? RESTful API? ???? ??? ???????.
- ?? ? ??
?? Composer? ???? REST ?? ?????? ???? ???. Composer.json ??? ?? ??? ?????.
{ "require": { "chriskacerguis/codeigniter-restserver": "^3.1" } }
?? ??? ???? REST ??? ?????.
composer install
?? ?? REST ?? ?????? ????? ???. CodeIgniter?? ?? ???? ???? REST ?? ?????? ??????.
$this->load->library('rest', array( 'rest_server' => array( 'server' => 'http://localhost', 'port' => 80, 'api_key' => 'YOUR_API_KEY', 'api_name' => 'YOUR_API_NAME', 'api_email' => 'YOUR_API_EMAIL', 'api_description' => 'YOUR_API_DESCRIPTION', 'api_maintenance' => FALSE ), 'rest_client' => array(), ));
- RESTful API ??
CodeIgniter?? RESTful API ??? ??? ??? HTTP ???? ?????. ??? ? ???? ?? ????? ???? ???? ???. ??? ????? ???? ?? ???? ?? ??? HTTP ??? ?????.
??? ??? ??? ?? ???(URI)? ???? ????.
<?php class Users extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('users_model'); $this->load->library('form_validation'); } public function index_get() { $users = $this->users_model->get_users(); $this->response($users, 200); } public function show_get($id) { $users = $this->users_model->get_user($id); $this->response($users, 200); } public function create_post() { $this->form_validation->set_rules('name', 'Name', 'required'); $name = $this->input->post('name'); if ($this->form_validation->run()) { $this->users_model->create_user($name); $this->response(['User created'], 200); } else { $this->response([ 'error' => true, 'message' => validation_errors() ], 422); } } public function update_put($id) { $this->form_validation->set_rules('name', 'Name', 'required'); $name = $this->input->put('name'); if ($this->form_validation->run()) { $this->users_model->update_user($id, $name); $this->response(['User updated'], 200); } else { $this->response([ 'error' => true, 'message' => validation_errors() ], 422); } } public function delete_delete($id) { $this->users_model->delete_user($id); $this->response(['User deleted'], 200); } }
?? ?? ??? ?? URI? ???? ???? ?????.
- GET /users - ?? ??? ??? ?????.
- GET /users/:id - ?? ??? ??? ?????.
- POST /users - ???? ?????.
- PUT /users/:id - ??? ??? ???????.
- DELETE /users/:id - ???? ?????.
??
? ???? CodeIgniter ?????? ???? MVC ??? RESTful API? ???? ??? ?? ??????. ??? CodeIgniter ?????? ? ??(??, ? ? ????)? ???? ??? ? ??????? ??? ??? ??????. ?? CodeIgniter?? ? ??? ??? ????? ? ??? ? ?? RESTful API? ???? ??????. ? ?? ??? CodeIgniter ?????? ???? MVC ??? RESTful API? ???? ??? ? ? ???? ? ??? ??? ????.
? ??? PHP ??: CodeIgniter? ???? MVC ?? ? RESTful API ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

??? ?? ??? ??? ?? JavaScript? MediareCorder API? ?? PHP ???? ???? ?????. 2. PHP? ???? ?? ??? ???? STTAPI (? : Google ?? Baidu ?? ??)? ???? ???? ?????. 3. PHP? ???? AI ??? (? : OpenAigpt)? ????. 4. ?? ?? PHP? TTSAPI (? : Baidu ?? Google ?? ??)? ???? ??? ?? ??? ?????. 5. PHP? ?? ??? ??? ??? ??? ?? ?? ??? ?????. ?? ????? PHP? ?? ???? ?? ?? ?? ??? ??? ?????.

PHP?? ?? ?? ??? ???? ?? ??? ? ???? ?? ??? ???? ?? ??? ???? ???? ????. 1. ?? ?? ??? ?? ??? URL ? ?? ??? ????. 2. UrlenCode? ???? ?? ??? ???????. 3. ? ???? ????? ?? ?? ??? ? ?? ??? ?????. 4. ???? ???? ?? ? ? ??? ??? ??? ??? ?????. 5. ??? ?? ??? ????? ?? ????? OG ??? ???? ?????. 6. XSS ??? ???? ?? ??? ??? ?????. ? ???? ??? ??? ???? ??? ?? ?? ??? ??? ???? ??? ?? ??? ?????.

AI? ??? ??? ?? ?? ? ?? ???? ????? ?? ??? ??????. 1. Baidu, Tencent API ?? ?? ?? NLP ?????? ?? ??? AI ?? ?? API? ??????. 2. PHP? ? ?? guzzle? ?? API? ???? ?? ??? ??????. 3. ?? ????? ?? ?? ??? ???? ???? ???? ??? ??? ? ????. 4. ?? ?? ? ?? ???? ?? PHP-L ? PHP_CODESNIFFER? ??????. 5. ???? ????? ???? ?? ?? ??? ?????? ??? ??????. AIAPI? ??? ? ???, ?? ??, ?? ? PHP ?? ??? ??? ???. ?? ???? PSR ??? ???, ??? ????? ????, ?? ??? ???, ????? ??? ????, X? ???????.

1. ?? ???? ??? ??? ?????? ?? ?? ??? ??, ??? ?? ???? ??? (? : ?? ???, ? ? ??), ?? ??? ?? ???? ???? ? ?? ?? ??? ??? ?? ??? ????????. 2. ?? ??? ??? ?? ? ??? ???? ?? ?? ?? ???? ?? ? ?? AUDIT ?? ??? ??? ? ????? ????? ??? ???????. 3. ?? ?? ??? ?? ??? ???????. Recaptchav3 ???? ??, ??? ?? ?? ?? ?? ??, IP ? ?? ??? ??? ??? ?? ???? ??? ?? ??? ????? ??? ???? ????? ??? ?????.

PHP? AI ??? ??? ?? ????? ??? API? ?? ?????. ??? ??? ????? ? ??? ???? ?????. API ??? ?? ?? ??? ???? ??? ??? ???? ???? ? ????. 2. ?? ?? ???? guzzle ?? curl? ???? HTTP ??? ???, JSON ??? ??? ? ???, API ? ?? ??, ??? ? ?? ??? ???? ??, ??? ?? ?? ? ? ?? ????, ??? ?? ? ?????? ?????. 3. ???? ???? ?? ???? API ??, ?? ? ??? ?? ??, ??? ?? ??, ?? ?? ? ??? ??? ??? ?????. ?? ??? ??? ??? ? ??? ???? Propt ?? ? ?? ?? ??, ??? ?? ? ?? ????, ?? ?? ?? ???? ? ??? ?? ? ???? ????? ?????.

PHP? ?????? ????? ?? ?? ?? ???? ???? ?? ???? ???? ?? ?? ???? ?????. 2. ?? ??? ???? ???? ?? ??? ?? ? ??? ??? ???? ?? API/Webhook ??? ??? ?? ???? ??? ??? ??? ??? ?????. 3. ?? ????? ?? ??, ??/???? ????, ???? ??, ???? ? ??? ?????? ????? ?? ??? ???? ???? ?? Dingtalk, SMS ?? ??? ???? ??? ?????? ???? ?? ? ??? ??? ????? ?? ??? ???? ???????.

PhpisstillRelevantinmodernenterpriseenvironments.1. Modernphp (7.xand8.x)? ??? ??, ??? ??, jitcompilation ? modernsyntax, mateitsuilableforlarge-scalepplications

??? AI ?? ?? ???? ???? PHPSDK? ??????. 2. PHP? ???? FFMPEG? ???? ???? API ?? ?? (? : WAV)?? ?????. 3. ??? ???? ????? ????? API ???? ??? ??????. 4. NLP ??? ???? JSON ??? ???? ???? ?????. 5. ?? ??? ???? ???? ?? ?? ?? ?? ?? ??? ?????. ?? ????? ?? ?? ? ??? ???? ?? ??? ???, ??? ?? ? ??? ???????.
