{"id":670,"date":"2023-11-15T23:59:28","date_gmt":"2023-11-15T14:59:28","guid":{"rendered":"https:\/\/web.cloudfree.jp\/journal\/?p=670"},"modified":"2023-11-21T17:32:34","modified_gmt":"2023-11-21T08:32:34","slug":"php-crud-api-%e3%82%92%e3%82%bb%e3%83%83%e3%83%88%e3%82%a2%e3%83%83%e3%83%97","status":"publish","type":"post","link":"https:\/\/web.cloudfree.jp\/journal\/php-crud-api-%e3%82%92%e3%82%bb%e3%83%83%e3%83%88%e3%82%a2%e3%83%83%e3%83%97\/","title":{"rendered":"php-crud-api \u3092\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7"},"content":{"rendered":"<h3 class=\"wp-block-post-title\">php-crud-api \u3092\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7<\/h3>\n\n\n<p class=\"has-tertiary-color has-text-color has-background has-small-font-size\" style=\"background-color:#8d8dd8;margin-top:0;margin-right:0;margin-bottom:0;margin-left:0;padding-top:0;padding-right:0;padding-bottom:0;padding-left:0\">2023-11-15 \u8a18\u8f09<br>\u6982\u8981 : \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u30c7\u30fc\u30bf\u3092http\u8d8a\u3057\u306bJSON\u3067\u8aad\u307f\u51fa\u3059PHP\u3092\u5165\u308c\u3066\u307f\u307e\u3057\u305f<br>Keyword : php-crud-api, PHP, \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9, create-read-update-delete,<\/p>\n\n\n\n<p>cloudfree\u3067\u306f\u5916\u90e8\u304b\u3089\u30c7\u30fc\u30bf\u30fc\u30d9\u30fc\u30b9\u306b\u63a5\u7d9a\u3067\u304d\u306a\u3044\u306e\u3067\u3001\u305d\u308c\u306b\u5909\u308f\u308b\u30c4\u30fc\u30eb\u304c\u4fbf\u5229\u306a\u3068\u304d\u304c\u3042\u308a\u307e\u3059\u3002<br>\u3053\u3053\u3067\u3044\u3046\u300c\u5916\u90e8\u304b\u3089\u300d\u306f\u3001\u3064\u307e\u308a\u306f\u30dd\u30fc\u30c83306\u3067\u63a5\u7d9a\u3067\u304d\u306a\u3044\u3001\u3068\u3044\u3046\u3053\u3068\u3067\u3042\u308a\u3001http\uff08Port=80 or 443\uff09\u306a\u3089\u5f53\u305f\u308a\u524d\u306b\u69cb\u308f\u306a\u3044\u308f\u3051\u3067\u3059\u3002<br>SQL\u6587\u305d\u306e\u307e\u307e\u3067\u306f\u306a\u3044\u3067\u3059\u304c\u3001\u30af\u30a8\u30ea\u3092\u6295\u3052\u305f\u3089\u30ec\u30b3\u30fc\u30c9\u3092JSON\u3067\u8fd4\u3057\u3066\u304f\u308c\u308b\u3001\u3068\u3044\u3046\u306e\u304c\u30bf\u30a4\u30c8\u30eb\u306ephp-crud-api\u3067\u3001<br><br>GitHub<br><a href=\"https:\/\/github.com\/mevdschee\/php-crud-api\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/mevdschee\/php-crud-api<\/a><br><br>composer\u306a\u3089<br>composer require mevdschee\/php-crud-api<br><br>\u30ed\u30fc\u30ab\u30eb\u306b\u74b0\u5883\u3092\u3082\u3063\u3066\u3044\u308c\u3070\u30ed\u30fc\u30ab\u30eb\u3067\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3057\u3066FTP\u3067\u3042\u3052\u308c\u3070OK\u3067\u3059\u3002\u30b5\u30fc\u30d0\u3067composer\u3092\u53e9\u304f\u5fc5\u8981\u306f\u3042\u308a\u307e\u305b\u3093\u3002<br><br>cloudfree\u306e\u5834\u5408\u3001\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u306e\u30d1\u30b9\u3092<br>C:\\home\\cfsid\\cfsid.cloudfree.jp\\public_html\\<br>\u306b\u3059\u308c\u3070\u4f55\u304b\u3068\u4fbf\u5229\u306a\u306e\u3067\u306f\u3068\u601d\u3044\u305d\u3046\u914d\u7f6e\u3057\u3066\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>cd C:\\home\\cfsid\\cfsid.cloudfree.jp\\public_html\\yoursetupfolder\n\nC:\\home\\cfsid\\cfsid.cloudfree.jp\\public_html\\yoursetupfolder&gt;composer require mevdschee\/php-crud-api\nUsing version ^2.14 for mevdschee\/php-crud-api\n.\/composer.json has been created\nRunning composer update mevdschee\/php-crud-api\nLoading composer repositories with package information\nUpdating dependencies\nLock file operations: 7 installs, 0 updates, 0 removals\n  - Locking mevdschee\/php-crud-api (v2.14.25)\n  - Locking nyholm\/psr7 (1.8.1)\n  - Locking nyholm\/psr7-server (1.1.0)\n  - Locking psr\/http-factory (1.0.2)\n  - Locking psr\/http-message (2.0)\n  - Locking psr\/http-server-handler (1.0.2)\n  - Locking psr\/http-server-middleware (1.0.2)\nWriting lock file\nInstalling dependencies from lock file (including require-dev)\nPackage operations: 7 installs, 0 updates, 0 removals\n  - Installing psr\/http-message (2.0): Extracting archive\n  - Installing psr\/http-server-handler (1.0.2): Extracting archive\n  - Installing psr\/http-server-middleware (1.0.2): Extracting archive\n  - Installing psr\/http-factory (1.0.2): Extracting archive\n  - Installing nyholm\/psr7-server (1.1.0): Extracting archive\n  - Installing nyholm\/psr7 (1.8.1): Extracting archive\n  - Installing mevdschee\/php-crud-api (v2.14.25): Extracting archive\n3 package suggestions were added by new dependencies, use `composer suggest` to see details.\nGenerating autoload files\n2 packages you are using are looking for funding.\nUse the `composer fund` command to find out more!\n<\/code><\/pre><\/div>\n\n\n\n<p>(2023-11-20\u6642\u70b9\u306e composer require mevdschee\/php-crud-api)<br><br>\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u914d\u7f6e\u3057\u305f\u3068\u3057\u307e\u3059\u3002<br>public_html\u76f4\u4e0b\u306b\u306f\u306a\u308b\u3079\u304f\u304a\u304b\u306a\u3044\u69cb\u60f3\u3068\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"191\" height=\"206\" src=\"https:\/\/web.cloudfree.jp\/journal\/wp-content\/uploads\/2023\/11\/api.jpg\" alt=\"\" class=\"wp-image-671\"\/><\/figure>\n\n\n\n<p>yoursetupfolder\u306b\u3001crud.php(\u30d5\u30a1\u30a4\u30eb\u540d\u306f\u5f8c\u306eURL\u3068\u5408\u308f\u305b\u305f\u3089\u306a\u3093\u3067\u3082\u3044\u3044)<br>\u3092\u4f5c\u6210\u3002\u305d\u306e\u4e2d\u8eab\u3092\u4ee5\u4e0b\u306b\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-php\" data-file=\"crud.php\" data-lang=\"PHP\"><code>&lt;?php\nnamespace Tqdev\\PhpCrudApi;\nrequire_once &quot;vendor\/autoload.php&quot;;\n\n    $config_mydata = [\n        &#39;debug&#39; =&gt; true,\n        &#39;driver&#39; =&gt; &#39;mysql&#39;,\n        &#39;port&#39; =&gt; &#39;3306&#39;,\n        &#39;address&#39; =&gt; &#39;localhost&#39;,\n        &#39;username&#39; =&gt; &#39;cfsid_dbuser&#39;,\n        &#39;password&#39; =&gt; &#39;password&#39;,\n        &#39;database&#39; =&gt; &#39;cfsid_defautconnectdb&#39;,\n    ];\n    \n    $config_base = [\n        &#39;driver&#39; =&gt; null,\n        &#39;address&#39; =&gt; null,\n        &#39;port&#39; =&gt; null,\n        &#39;username&#39; =&gt; &#39;&#39;,\n        &#39;password&#39; =&gt; &#39;&#39;,\n        &#39;database&#39; =&gt; &#39;&#39;,\n        &#39;command&#39; =&gt; &#39;&#39;,\n        &#39;tables&#39; =&gt; &#39;all&#39;,\n        &#39;mapping&#39; =&gt; &#39;&#39;,\n        &#39;middlewares&#39; =&gt; &#39;cors&#39;,\n        &#39;controllers&#39; =&gt; &#39;records,geojson,openapi,status&#39;,\n        &#39;customControllers&#39; =&gt; &#39;&#39;,\n        &#39;customOpenApiBuilders&#39; =&gt; &#39;&#39;,\n        &#39;cacheType&#39; =&gt; &#39;TempFile&#39;,\n        &#39;cachePath&#39; =&gt; &#39;&#39;,\n        &#39;cacheTime&#39; =&gt; 10,\n        &#39;jsonOptions&#39; =&gt; JSON_UNESCAPED_UNICODE,\n        &#39;debug&#39; =&gt; false,\n        &#39;basePath&#39; =&gt; &#39;&#39;,\n        &#39;openApiBase&#39; =&gt; &#39;{&quot;info&quot;:{&quot;title&quot;:&quot;PHP-CRUD-API&quot;,&quot;version&quot;:&quot;1.0.0&quot;}}&#39;,\n        &#39;geometrySrid&#39; =&gt; 4326,\n    ];\n    \n    $config = new Config\\Config(array_merge($config_base, $config_mydata));\n    $api = new Api($config);\n    ResponseUtils::output($api-&gt;handle(RequestFactory::fromGlobals()));\n<\/code><\/pre><\/div>\n\n\n\n<p>$config_base \u306e\u5185\u5bb9\u306f<br>\\vendor\\mevdschee\\php-crud-api\\src\\Tqdev\\PhpCrudApi\\Config\\Config.php<br>\u5185\u306b\u8a18\u8f09\u306e\u4e38\u3054\u3068\u30b3\u30d4\u30fc\u3067\u3059\u3002<br>\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u3042\u3052\u305f\u5834\u5408\u3001\u30b3\u30d4\u30fc\u3057\u306a\u304a\u3057\u3066\u304f\u3060\u3055\u3044\u3002<br>\u305d\u308c\u3092 $config_mydata \u3067\u4e00\u90e8\u4e0a\u66f8\u304d\u3057\u3066\u307e\u3059\u3002<br><br>\u3053\u308c\u3067yoursetupfolder\u30d5\u30a9\u30eb\u30c0\u4e38\u3054\u3068\u3092\u30b5\u30fc\u30d0\u3078\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3002<br><br>crud.php<br>\u306e<br>$config_mydata<br>\u306e<br>&#8216;database&#8217; =&gt; &#8216;cfsid_defautconnectdb&#8217;,<br>\u304c<br>WordPress\u7528\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3060\u3063\u305f\u3068\u3057\u3066\u3001<br><br>https:\/\/cfsid.cloudfree.jp\/yoursetupfolder\/crud.php\/records\/wp_options\/<br><br>\u3068\u3059\u308c\u3070\u4ee5\u4e0b\u306e\u3088\u3046\u306bJSON\u30c7\u30fc\u30bf\u304c\u5f97\u3089\u308c\u307e\u3059\u3002(\u753b\u9762Edge)<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>{\n    &quot;records&quot;: [\n        {\n            &quot;option_id&quot;: 1,\n            &quot;option_name&quot;: &quot;siteurl&quot;,\n            &quot;option_value&quot;: &quot;https:\/\/cfsid.cloudfree.jp\/mywp&quot;,\n            &quot;autoload&quot;: &quot;yes&quot;\n        },\n        {\n            &quot;option_id&quot;: 2,\n            &quot;option_name&quot;: &quot;home&quot;,\n            &quot;option_value&quot;: &quot;https:\/\/cfsid.cloudfree.jp\/mywp&quot;,\n            &quot;autoload&quot;: &quot;yes&quot;\n        },\n        {\n            &quot;option_id&quot;: 3,\n            &quot;option_name&quot;: &quot;blogname&quot;,\n            &quot;option_value&quot;: &quot;\u308f\u305f\u3057\u306eBlog\u30ef\u30fc\u30c9\u30d7\u30ec\u30b9&quot;,\n            &quot;autoload&quot;: &quot;yes&quot;\n        },\n        {\n            &quot;option_id&quot;: 4,\n            &quot;option_name&quot;: &quot;blogdescription&quot;,\n            &quot;option_value&quot;: &quot;\u308f\u305f\u3057\u306eBlog\u30ef\u30fc\u30c9\u30d7\u30ec\u30b9\u306e\u305b\u3064\u3081\u3044&quot;,\n            &quot;autoload&quot;: &quot;yes&quot;\n        },\n\u2026\u2026\u4ee5\u4e0b\u5168\u30ec\u30b3\u30fc\u30c9<\/code><\/pre><\/div>\n\n\n\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3054\u3068\u306bcrud.php\u3092\u7528\u610f\u3059\u308b\u306e\u306f\u9762\u5012\u306a\u306e\u3067<br>\u958b\u767a\u7528\u3068\u3057\u3066database\u3082URL\u30d1\u30e9\u30e1\u30fc\u30bf\u3067\u6e21\u305b\u308b\u3088\u3046\u306b\u6539\u9020\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-php\" data-file=\"crud.php\" data-lang=\"PHP\"><code>    $database = $_GET[&#39;database&#39;] ?? &#39;cfsid_defautconnectdb&#39;;\n    \n    $config_mydata = [\n        &#39;debug&#39; =&gt; true,\n        &#39;driver&#39; =&gt; &#39;mysql&#39;,\n        &#39;port&#39; =&gt; &#39;3306&#39;,\n        &#39;address&#39; =&gt; &#39;localhost&#39;,\n        &#39;username&#39; =&gt; &#39;cfsid_dbuser&#39;,\n        &#39;password&#39; =&gt; &#39;password&#39;,\n        &#39;database&#39; =&gt; $database,\n    ];\n<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u30c7\u30fc\u30bf\u3092http\u8d8a\u3057\u306bJSON\u3067\u8aad\u307f\u51fa\u3059\u3001php-crud-api\u3092\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3002<\/p>\n","protected":false},"author":1,"featured_media":672,"comment_status":"open","ping_status":"closed","sticky":false,"template":"wp-custom-template-x24-index","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[13,59,58,23,72,18],"_links":{"self":[{"href":"https:\/\/web.cloudfree.jp\/journal\/wp-json\/wp\/v2\/posts\/670"}],"collection":[{"href":"https:\/\/web.cloudfree.jp\/journal\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/web.cloudfree.jp\/journal\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/web.cloudfree.jp\/journal\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/web.cloudfree.jp\/journal\/wp-json\/wp\/v2\/comments?post=670"}],"version-history":[{"count":0,"href":"https:\/\/web.cloudfree.jp\/journal\/wp-json\/wp\/v2\/posts\/670\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/web.cloudfree.jp\/journal\/wp-json\/wp\/v2\/media\/672"}],"wp:attachment":[{"href":"https:\/\/web.cloudfree.jp\/journal\/wp-json\/wp\/v2\/media?parent=670"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/web.cloudfree.jp\/journal\/wp-json\/wp\/v2\/categories?post=670"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/web.cloudfree.jp\/journal\/wp-json\/wp\/v2\/tags?post=670"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}