<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Pao Phouminith on Medium]]></title>
        <description><![CDATA[Stories by Pao Phouminith on Medium]]></description>
        <link>https://medium.com/@p40pmn?source=rss-27d932b42a6e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*F9a_jY7arfk7ugWSzRD_Iw.jpeg</url>
            <title>Stories by Pao Phouminith on Medium</title>
            <link>https://medium.com/@p40pmn?source=rss-27d932b42a6e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 08:20:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@p40pmn/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[[GCP Cloud SQL] Connect to Cloud SQL for PostgreSQL from Cloud Run]]></title>
            <link>https://medium.com/laoitdev/gcp-cloud-sql-connect-to-cloud-sql-for-postgresql-from-cloud-run-844973b4d9ea?source=rss-27d932b42a6e------2</link>
            <guid isPermaLink="false">https://medium.com/p/844973b4d9ea</guid>
            <category><![CDATA[google-cloud-run]]></category>
            <category><![CDATA[backenddev]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[google-cloud-sql]]></category>
            <category><![CDATA[postgresql]]></category>
            <dc:creator><![CDATA[Pao Phouminith]]></dc:creator>
            <pubDate>Fri, 17 Mar 2023 02:20:01 GMT</pubDate>
            <atom:updated>2023-03-17T02:45:57.619Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nW99Q5O1XYp7HbPVcZ-oEg.jpeg" /><figcaption>CHOCO wants to sleep</figcaption></figure><p>ຫລັງຈາກບົດຄວາມກ່ອນໜ້ານີ້ເຮົາໄດ້ລອງຂຽນ Sample API ແລ້ວ <a href="https://medium.com/laoitdev/gcp-cloud-run-%E0%BA%A1%E0%BA%B2%E0%BA%A5%E0%BA%AD%E0%BA%87-hello-choco-%E0%BA%94%E0%BB%89%E0%BA%A7%E0%BA%8D-cloud-run-%E0%BA%81%E0%BA%B1%E0%BA%99%E0%BB%80%E0%BA%96%E0%BA%B2%E0%BA%B0-2af8f956a806"><em>Deploy to Google Cloud Run</em></a><em> </em>ກັນໄປແລ້ວ ມື້ນີ້ເຮົາມາລອງຂຽນ API ທີ່ fetch ຂໍ້ມູນມາຈາກ Database <a href="https://www.postgresql.org/docs/">PostgreSQL</a> ຂອງ <a href="https://cloud.google.com/sql">Google Cloud SQL</a>. (source code <a href="https://gitlab.com/phuangpheth.litd/halokitty/-/tree/main/cloudrun">here</a>)</p><h4>ສິ່ງທີ່ໃຊ້:</h4><ul><li><a href="https://go.dev/"><strong>Golang</strong></a> ໃຊ້ສຳລັບສ້າງ API</li><li><a href="https://www.postgresql.org/"><strong>PostgreSQL</strong></a> hosted on Google Cloud SQL ໃຊ້ເກັບຂໍ້ມູນ</li><li><a href="https://cloud.google.com/run"><strong>Google Cloud Run</strong></a> ໃຊ້ Deploy API</li><li><a href="https://cloud.google.com/sql/docs/postgres/sql-proxy"><strong>Google Cloud SQL Proxy</strong></a> ໃຊ້ເຊື່ອມຕໍ່ Cloud SQL</li><li><a href="https://cloud.google.com/artifact-registry"><strong>Google Cloud Artifact Registry</strong></a> ໃຊ້ເກັບ Container Images</li><li><a href="https://docs.docker.com/"><strong>Docker</strong></a> ໃຊ້ build container image</li><li><a href="https://about.gitlab.com/"><strong>Gitlab</strong></a> ໃຊ້ເກັບ Source code</li><li><a href="https://github.com/golang-migrate/migrate"><strong>Migration CLI</strong></a> ໃຊ້ migrate ຂໍ້ມູນເຂົ້າ database</li></ul><h3># What is Google Cloud SQL? (ແບບສັ້ນໆ)</h3><blockquote>Fully managed relational database service for MySQL, PostgreSQL, and SQL Server with rich extension collections, configuration flags, and developer ecosystems. (<a href="https://cloud.google.com/sql">reference</a>)</blockquote><p>Cloud SQL ເປັນບໍລິການຖານຂໍ້ມູນແບບ Relational Database ທີ່ເປັນການ Run Software ຖານຂໍ້ມູນແບບ Fully managed. ປັດຈຸບັນມີຢູ່ 3 ຄ້າຍໃຫ້ເລືອກຄື MySQL, PostgreSQL ແລະ SQL Server. (ໃນບົດຄວາມນີ້ຜູ້ຂຽນເລືອກໃຊ້ PostgreSQL)</p><blockquote>Fully managed ແມ່ນໝາຍເຖິງທີມງານ GCP(Google Cloud Platform) ຈະເບິ່ງແຍ ແລະ ຈັດການໃນເລື່ອງຂອງ Infrastructure ໃຫ້.</blockquote><h3># ສ້າງ Cloud SQL Instance</h3><p>ຫົວຂໍ້ນີ້ຈະແນະນຳຂັ້ນຕອນໃນການສ້າງ Cloud SQL Instance ຫລື ເຄື່ອງທີ່ໃຊ້ Run Database ນັ້ນເອງ. ເຊິ່ງຂັ້ນຕອນດັ່ງກ່າວນີ້ແມ່ນຈະເຮັດຜ່ານ Google Cloud Console.</p><ol><li>ເປີດ <a href="https://console.cloud.google.com/">Google Cloud Console</a></li><li>ຢູ່ເມນູເບື້ອງຊ້າຍໃຫ້ເລືອກເມນູ <a href="https://console.cloud.google.com/sql">SQL</a> ເຊິ່ງມັນຈະຢູ່ໝວດຂອງ Database</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/252/1*yO3Rhto6doxKvNqHPrr3Qg.png" /></figure><p>3. ເມື່ອເຂົ້າໄປໜ້າທີ່ສະແດງລາຍການຂອງ Instance ທີ່ເຮົາມີສຳຫລັບ SQL ແລ້ວໃຫ້ເຮົາກົດ “<strong>Create Instance</strong>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*bQSoLvPzOVsh06QxsWdAqA.png" /></figure><p>4. ຫລັງຈາກກົດປຸ່ມ “<strong>Create Instance</strong>” ລະບົບຈະໃຫ້ເຮົາເລືອກ Database Engine ທີ່ຈະໃຊ້ແນ່ນອນໃນບົດຄວາມນີ້ເຮົາຈະໃຊ້ PostgreSQL. ກົດປຸ່ມ “<strong>Choose</strong> <strong>PostgreSQL”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hZzQ-x0rZlXnI23w43FNrw.png" /></figure><p>5. ສຳຫລັບຊ່ອງຂອງ <strong>Instance ID </strong>ໃນໜ້າ Instance info ໃຫ້ປ້ອນຊື່ທີ່ເຮົາຕ້ອງການໃສ່ໄດ້ເລີຍ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*EAPapJDYWYvQ0L1bhT8QwQ.png" /></figure><p>5. ໃນຊ່ອງ <strong>Password</strong> ແມ່ນເປັນການຕັ້ງລະຫັດຜ່ານສຳຫລັບ R<strong>oot User</strong>.</p><ul><li>ສຳຫລັບ <strong>Password Policy</strong> ຖ້າຫາກເປີດໃຊ້ ເວລາທີມີການສ້າງ User ຫລື ປ່ຽນລະຫັດຜ່ານໃຫ້ User ຈະຕ້ອງໄດ້ໃຊ້ລະຫັດທີ່ຕັ້ງໄວ້ໃນ Password Policy ນີ້ສຳຫລັບ Verify ທຸກຄັ້ງທີ່ມີການດຳເນີນການ.</li></ul><p>6. ໃນສ່ວນຂອງ <strong>Database version</strong> ແມ່ນເລືອກ version ຂອງ database ທີ່ຈະໃຊ້, ຜູ້ຂຽນຈະເລືອກໃຊ້ <strong>Postgrsql12</strong>.</p><p>7.<strong> Choose a configuration to start with</strong></p><p>ກຳນົດປະເພດຂອງທີ່ເຮົາຈະໃຊ້ເຊິ່ງຈະແຍກອອກເປັນ <strong>Production</strong>, <strong>Development</strong> ແລະ <strong>Sandbox</strong>.</p><ul><li>ການເລືອກໃນສ່ວນນີ້ລະບົບຈະ <strong>pre-fill</strong> ຂໍ້ມູນໃຫ້ສຳຫລັບ spec ຂອງເຄື່ອງທີ່ຈະສ້າງຕາມປະເພດທີ່ເລືອກ ແລະ ຂໍ້ມູນດັ່ງກ່າວເຮົາຍັງສາມາດໄປ Custom ໄດ້ເອງຕື່ມອີກ. ໃນສ່ວນນີ້ຜູ້ຂຽນຈະເລືອກເປັນ Sandbox ເພາະຂະໜາດນ້ອຍ.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*hrGc8-SOL37SzL6rbX7ZDQ.png" /></figure><p>8. <strong>Choose region and zonal availability</strong></p><ul><li><strong>Region</strong> ແມ່ນເປັນບ່ອນທີ່ <strong>Instance</strong> ຈະຖືກສ້າງຂື້ນ</li><li>ສຳຫລັບ <strong>Zonal availability </strong>ແມ່ນເປັນການກຳນົດວ່າງຈະສ້າງ <strong>Instance</strong> ຂື້ນມາສະເພາະ <strong>Zone (Single Zone)</strong> ຫລື ວ່າຕ້ອງການແບບ <strong>Multi Zones</strong>. ຈະເລືອກເປັນ <strong>Signal zone.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*PVsvkzkNIT1SdfdX3RzuxA.png" /></figure><ul><li>ຖ້າຫາກເລືອກເປັນ Multi zones ຈະຕ້ອງໄດ້ກຳນົດວ່າຈະໃຊ້ zone ໃດເປັນຕົວຫລັກ ແລະ zone ໃດເປັນຕົວສຳຮອງ</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*ZK-gHwf4cD9iffD9foBCYA.png" /></figure><p>9. <strong>Customize your instance</strong></p><ul><li><strong>Mechine Type:</strong> ເປັນປະເພດເຄື່ອງທີ່ຈະໃຊ້ເຊິ່ງຈະມີ <strong>Shared core</strong>, <strong>Lightweight, Standard ແລະ High memory</strong>. ໃນບົດຄວາມນີ້ເຮົາຈະເລືອກເປັນປະເພດ Shared core ແລະ ເລືອກຕົວທີ່ spec ຕ່ຳສຸດ (ປະຢັດງົບ 5555).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*3lDe3Wa78A10O5IS7fRXzA.png" /></figure><ul><li><strong>Storage</strong>: ເປັນປະເພດ ແລະ ຄວາມຈຸຂອງ storage ທີ່ຈະໃຊ້ສຳຫລັບ instance ທີ່ຈະສ້າງ</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*Hax60V54V2EyzS8Vo_yTWA.png" /></figure><blockquote>ສຳຫລັບສ່ວນອື່ນໆເຊັນ Connections, Data Protection, Maintenance, Flags, Query insights ແລະ Labels ແມ່ນຈະປະເປັນຄ່າ Default ໄປກ່ອນ.</blockquote><ul><li><strong>Connections:</strong> ເປັນບ່ອນກຳນົດຊ່ອງທາງທີ່ຈະ connect ເຂົ້າຫາ instance ທີ່ຈະສ້າງ ໂດຍ Default ຊ່ອງຂອງ Public IP ຈະຖືກເລືອກໄວ້ເພື່ອໃຫ້ສາມາດ connect ເຂົ້າໄປຫາ instance ຈາກພາຍນອກໄດ້ (ໃນບົດຄວາມນີ້ຈະໃຊ້ <a href="https://cloud.google.com/sql/docs/mysql/connect-instance-auth-proxy#gcloud">Google Cloud SQL Proxy</a> )</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*_WAg1tv2wax_RH_ALZDu4Q.png" /></figure><ul><li><strong>Data Protection: </strong>ເປັນກຳນົດການເຮັດ Back Up, Recovery ແລະ instance deletion protection.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*Yo9w5ROsQsgkZtnkFnMWeA.png" /></figure><ul><li><strong>Maintenance</strong>: ເປັນບ່ອນກຳນົດໃຫ້ instance ສາມາດ restart ເຄື່ອງໄດ້ເມື່ອມີການ update. ການ update ໃນທີ່ນີ້ໝາຍເຖິງການອັບທີ່ທາງທີມງານຂອງ GCP ເປັນຄົນຈັດການ ແຕ່ສຳຫລັບການກຳນົດວ່າຈະໃຫ້ update ໄດ້ ຫລື ບໍ່ໄດ້ ນັ້ນແມ່ນເຮົາເປັນຄົນກຳນົດເອງ</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*Al4XOzSLXuSYeXEPc7UQaQ.png" /></figure><ul><li><strong>Flags</strong>: ເປັນບ່ອນກຳນົດ Script ທີ່ເຮົາຢາກໃຫ້ instance ຂອງເຮົາ Run ເມື່ອ Start</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*fQf07waiVnIxMbR6mJVddQ.png" /></figure><ul><li><strong>Query insights</strong>: ຖ້າ enable ເຮົາຈະສາມາດເບິ່ງໄດ້ວ່າໃນ instance ຂອງເຮົາມີ queries ຫລາຍປານໃດແລ້ວທີ່ຖືກ executed ແລະ ສາມາດເບິ່ງລາຍລະອຽດຂອງ query ນັ້ນໄດ້</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*U8NY4PMdePrrvXUo_KbAAA.png" /></figure><ul><li><strong>Labels</strong>: ເປັນ Key-Value pair ເພື່ອຊ່ວຍໃນການຈັດການກັບ Resource ທີ່ເຮົາໃຊ້ ສາມາດໃຊ້ເພື່ອເຮັດ filter resource ໄດ້ຈາກຊື່ຂອງ Labels ທີ່ເຮົາໄດ້ຕັ້ງໄວ້</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*zuu8uQYvfbB7xS8X8Tq-8Q.png" /></figure><p>10. ເມື່ອກຳນົດຄ່າຕາມທີ່ຕ້ອງການແລ້ວກົດ “<strong>Create Instance</strong>”</p><p>ສຳຫລັບການສ້າງແມ່ນຈະໃຊ້ເວລາໜ້ອຍໜຶ່ງປະມານ 5 ນາທີ ຫລື ຫລາຍກວ່ານັ້ນ ……………… (ຖ້າແບບໃຈເຢັນເດີ້)</p><p>ຫລັງຈາກສ້າງສຳເລັດກໍຈະໄດ້ instance ID ຕາມທີ່ໄດ້ກຳນົດໄວ້ໃນຂັ້ນຕອນການສ້າງ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*7m67jnhNrvjnZV-CWbNXSA.png" /></figure><p>11. ກົດທີ່ “<strong>instance ID</strong>” ຂອງຜູ້ຂຽນແມ່ນຊື່ “<strong>choco</strong>” ເພື່ອສ້າງ Database ແລະ User ທີ່ຈະໃຊ້ສຳຫລັບເຮັດ connection. ເມື່ອກົດແລ້ວຈະເຂົ້າໄປທີ່ໜ້າ Overview ຂອງ instance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4U5dyfMbIjCdnKMt7PLxPw.png" /></figure><p>12. ກົດທີ່ເມນູ “<strong>Users</strong>” ແລ້ວກົດ “<strong>Add User Account</strong>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*5oQep0duG78CSLazj22nhg.png" /></figure><p>ໃນການ <strong>Add user account</strong> ຈະມີໃຫ້ເລືອກ <strong>2</strong> ແບບຄື: ແບບ <strong>Built-in authentication</strong> ແລະ ແບບ <strong>Cloud IAM</strong> (ໃນບົດຄວາມນີ້ເຮົາຈະສ້າງແບບ <strong>Built-in authentication</strong>).</p><ul><li><strong>User name</strong>: ເປັນຊື່ຂອງ User ທີ່ເຮົາກຳນົດເອງ</li><li><strong>Password</strong> ເປັນລະຫັດຜ່ານທີ່ຈະໃຊ້ສຳຫລັບ User ນີ້</li><li>ຫລັງຈາກປ້ອນຂໍ້ມູນສຳເລັດກົດ “<strong>Add</strong>”</li></ul><p>13. ກົດທີ່ເມນູ “<strong>Database</strong>” ແລ້ວກົດ “<strong>Create Database</strong>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*VerXac_xnvgHyIC5SRdJPg.png" /></figure><ul><li><strong>Database Name</strong>: ກຳນົດຊື່ຂອງ Database ທີ່ຕ້ອງການ (ຂອງຜູ້ຂຽນແມ່ນຈະຕັ້ງເປັນ “<strong>choco</strong>”)</li><li>ກົດ “<strong>Create</strong>” ເພື່ອສ້າງ, ເມື່ອສ້າງສຳເລັດກໍຈະໄດ້ Database ທີ່ເຮົາສ້າງຂື້ນມາສະແດງໃນລາຍການຂອງ Databases</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*VLGxcBXe_J-r-V9l8fWKtw.png" /></figure><p>ສຳຫລັບຂັ້ນຕອນຂອງການ set up database ຢູ່ Cloud SQL ຕອນນີ້ແມ່ນພ້ອມໃຫ້ເຮົາ connect ເຂົ້າໄປໃຊ້ແລ້ວ.</p><h3># ໃຊ້ Google Cloud SQL Proxy</h3><ol><li>ເປີດ terminal ທີ່ຖະນັດຂື້ນມາ</li></ol><ul><li>ຖ້າຫາກຍັງບໍ່ໄດ້ install Google Cloud SQL Proxy ສາມາດປະຕິບັດຕາມ <a href="https://cloud.google.com/sql/docs/mysql/connect-instance-auth-proxy#linux-64-bit">docs</a> ໄດ້</li></ul><p>2. Command ໃຊ້ໃນການ connect ໄປຫາ Cloud SQL</p><pre>cloud_sql_proxy -instances={instance-connection}={TCP-server} -enable_iam_login</pre><ul><li><strong>instance-connection: </strong>ແມ່ນສາມາດເຂົ້າໄປເອົາຢູ່ທີ່ <strong>instance</strong> ທີ່ເຮົາສ້າງໄດ້. ໄປທີ່ເມນູ “<strong>Connections</strong>” ແລ້ວ copy ເອົາ <strong>connection name</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*kkNHWFwoGfBs4LsH2NibVw.png" /></figure><blockquote>ເຮົາຈະໄດ້ connection name “phuangpheth:asia-southeast1:choco”</blockquote><ul><li><strong>TCP-server</strong>: ເປີດ TCP connection ຢູ່ເຄື່ອງ Local e.g., “tcp:0.0.0.0:port”</li><li><strong>-enable_iam_login</strong>: enable ໃຫ້ database user authentication ດ້ວຍ Cloud SQL’s IAM DB Authentication (Postgres only).</li></ul><blockquote>ສາມາດເບິ່ງຂໍ້ມູນເພີ່ມຕື່ມສຳຫລັບການໃຊ້ <strong>cloud_sql_proxy</strong> ໄດ້ໂດຍການເພີ່ມ “ <strong>— help</strong>”</blockquote><p>ເມື່ອປະກອບຂໍ້ມູນສຳເລັດຈະໄດ້ Command ດັ່ງນີ້:</p><pre>cloud_sql_proxy -instances=phuangpheth:asia-southeast1:choco=tcp:127.0.0.1:5432 -enable_iam_login</pre><p>3. ລອງເອົາ Command ມາ Run ເພື່ອທົດສອບວ່າເຮົາສາມາດ connect ໄປຫາ Cloud SQL ຂອງເຮົາໄດ້ແທ້ບໍ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EXq6ds1pV63FpMJJ-Nx6yg.png" /></figure><p>ເຢ້ connect ໄດ້ແລ້ວວວວວ</p><blockquote>#<strong>Note</strong>: ຕ້ອງໄດ້ Run command ນີ້ປະໄວ້ຖ້າເຮົາຕ້ອງການທີ່ຈະ connect ໄປ Cloud SQL. ເມື່ອໃດທີ່ເຮົາປິດ ເຮົາຈະບໍ່ສາມາດໃຊ້ Cloud SQL ຢູ່ເຄື່ອງ Local ຂອງເຮົາໄດ້</blockquote><p>ຫລັງຈາກ Run Command ເພື່ອສ້າງ connection ໄວ້ແລ້ວ ເຮົາມາໃຊ້ User ທີ່ເຮົາສ້າງໄວ້ເພື່ອ Login ເຂົ້າໄປໃຊ້ງານ. ຈະໃຊ້ <a href="https://www.postgresql.org/docs/current/app-psql.html">psql</a> ສຳຫລັບ interact with Postgres</p><pre>psql -U {username}-p 5432 -d {databaseName} -W</pre><ul><li><strong>username</strong>: ແມ່ນ user name ທີ່ໄດ້ຈາກຂັ້ນຕອນ <strong>Add User Account</strong></li><li><strong>databaseName</strong>: ແມ່ນ database name ທີ່ໄດ້ຈາກຂັ້ນຕອນ <strong>Create Database</strong></li></ul><p>ຈະໄດ້ command ດັ່ງນີ້:</p><pre>psql -U choco -p 5432 -d choco -W</pre><p>ເມື່ອກົດ “enter” ມັນຈະໃຫ້ເຮົາປ້ອນລະຫັດຜ່ານ (ລະຫັດຜ່ານທີ່ໄດ້ສ້າງໃນຂັ້ນຕອນ Add User Account).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*vzvf87kUr7y-qzFzAkccNw.png" /></figure><p>ເຢ້ໆ login ເຂົ້າໃຊ້ database ທີ່ເຮົາສ້າງໄວ້ໄດ້ແລ້ວວວວ</p><h3># ໃຊ້ <strong>Migration CLI</strong></h3><p>Migration CLI ໃຊ້ສຳຫລັບເຮັດ migrate database ແບບ Step Up ຫລື Step Down ໄດ້ເມື່ອປ່ຽນ Schema (<a href="https://github.com/golang-migrate/migrate">More info</a>)</p><ol><li>Command ເບື່ອງຕົ້ນ ແລະ ອະທິບາຍການໃຊ້ງານ(ແບບສັ້ນໆ)</li></ol><ul><li>Command ໃນການສ້າງ files</li></ul><pre>migrate create -dir {directory} -seq -ext sql init</pre><p><strong>directory </strong>ເປັນບ່ອນທີ່ຈະໃຫ້ migrate ເກັບ files ໄວ້</p><p>ຫລັງຈາກທີ່ Run command ດ້ານເທີງຕົວ migrate ຈະສ້າງ Folder ຕາມທີ່ເຮົາໄດ້ກຳນົດໄວ້ພ້ອມທັງ files ທີ່ເປັນ Up ແລະ Down</p><ul><li>Up ເປັນ file ທີ່ໃຊ້ສຳຫລັບ upgrade ໃຫ້ database ເປັນ version ຖັດໄປ</li><li>Down ເປັນ file ທີ່ໃຊ້ສຳຫລັບ downgrade ໃຫ້ database ເປັນ version ກ່ອນຫນ້າທີ່ file ຖືກສ້າງຂື້ນ</li></ul><p><strong>ຕົວຢ່າງ</strong>: ປັດຈຸຸບັນໃນ database ມີ table ທີ່ຊື່ວ່າ users ເຊິ່ງ version ປັດຈຸບັນມີ columns ດັ່ງນີ້:</p><pre>CREATE TABLE users(<br>  id TEXT NOT NULL PRIMARY KEY,<br>  display_name TEXT NOT NULL<br>);</pre><p>ສຳຫລັບການແກ້ໄຂແມ່ນຈະເພີ່ມ columns email ປະເພດຂໍ້ມູນເປັນ text ເຂົ້າ table users</p><ul><li>Run migrate command</li></ul><pre>migrate create -dir {directory} -seq -ext sql init</pre><ul><li>ສຳຫລັບ file up</li></ul><pre>ALTER TABLE users<br>ADD email TEXT NOT NULL;</pre><ul><li>ສຳຫລັບ file down</li></ul><pre>ALTER TABLE users<br>DROP COLUMN email;</pre><p>ຈະເຫັນໄດ້ວ່າ <strong>file up</strong> ໃຊ້ເພີ່ມ<strong> column email</strong> ເຂົ້າ table <strong>users<em>. </em></strong>ໃນສ່ວນຂອງ<strong><em> </em>file down</strong> ໃຊ້ລຶບ <strong>column email</strong> ອອກຈາກ <strong>table users</strong> ເຊິ່ງເປັນ <strong>version</strong> ປັດຈຸບັນກ່ອນທີ່<strong> file up</strong> ຈະຖືກ <strong>execute</strong>.</p><ul><li>Command ສຳຫລັບ run up ຫລື down version</li></ul><pre>migrate -path {directory} -database &quot;{databaseURL}&quot; -verbose up/down</pre><p><strong>- databaseURL: </strong>url ຂອງ database ທີ່ຕ້ອງການ migrate ຂໍ້ມູນ (ຕ້ອງໄດ້ໃສ່ຊື່ຂອງ database ພ້ອມ)<br>- <strong>directory</strong>: ທີ່ຢູ່ຂອງ files migration (ໃສ່ຮອດແຕ່ Folder)<br>- <strong>up/down</strong>: ຖ້າໃຊ້ up ຕົວ migrate ຈະ execute file up, ຖ້າໃຊ້ down ຕົວ migrate ຈະ execute file down</p><p>ຕົວຢ່າງ command ໃນການ execute file up:</p><pre>migrate -path migrations -database &quot;postgresql://root:101023@127.0.0.1:5455/choco?sslmode=disable&quot; -verbose up</pre><p>ໃນຕົວຢ່າງແມ່ນຈະເຮັດ migrate ຈາກ folder ທີ່ຊື່ວ່າ migrations ເຂົ້າ database.<br>ເຊິ່ງແຍກຂໍ້ມູນຈາກ command ອອກມາກໍຈະໄດ້ດັ່ງນີ້:</p><blockquote>- <strong>driver</strong>: postgresql<br>- <strong>host</strong>: 127.0.0.1 (localhost ນັ້ນເອງ) <br>- <strong>port</strong>: 5455 <br>- <strong>user</strong>: root<br>- <strong>password</strong>: 101023<br>-<strong> database</strong>: choco</blockquote><p>2. ສ້າງ Table products ດ້ວຍ Migrate CLI</p><ul><li>Run command ເພື່ອໃຫ້ migrate ສ້າງ files ໄວ້ໃນ folder migrations</li></ul><pre>migrate create -dir migrations -seq -ext sql init</pre><p>ຈະໄດ້ folder ຊື່ migrations ແລະ files ດັ່ງນີ້:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/294/1*RMdpTNfDthHtLSl-6KLiKQ.png" /></figure><ul><li>file up ມີ code ດັ່ງນີ້</li></ul><pre><br>CREATE TABLE products(<br>  id TEXT NOT NULL PRIMARY KEY,<br>  display_name TEXT NOT NULL,<br>  currency TEXT NOT NULL,<br>  price DECIMAL(18,2) NOT NULL,<br>  qty DECIMAL(10,2) NOT NULL,<br>  created_at TIMESTAMPTZ DEFAULT NOW(),<br>  updated_at TIMESTAMPTZ DEFAULT NOW()<br>);<br></pre><ul><li>file down ມີ code ດັ່ງນີ້</li></ul><pre><br>DROP TABLE IF EXISTS products;</pre><ul><li>Run migration up ເພື່ອເລີ່ມ migrate</li></ul><pre><br>migrate -path directory -database &quot;driverName://user:password@host:port/db_name?sslmode=disable&quot; -verbose up</pre><p>migrate ສຳເລັດຈະໄດ້</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZJFfNiEk6jNBq8FWaMWZmQ.png" /></figure><p>ເມື່ອເຂົ້າໄປກວດເບິ່ງໃນ database ທີ່ເຮົາ migrate ກໍຈະເຫັນ<strong> table products</strong> ແລະ <strong>schema_migrations(</strong>ເປັນ table ທີ່ໃຊ້ສຳຫລັບຕິດຕາມວ່າປັດຈຸບັດ database ຂອງເຮົາໄດ້ migrate ຮອດ version ໃດແລ້ວ<strong>)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*bVtpoWpIpWxvtuBsgZgNcw.png" /></figure><h3><strong># Update Golang API ໃຫ້ດຶງຂໍ້ມູນຈາກ table products ມາເປັນ Response</strong></h3><ol><li>file main.go</li></ol><pre>package main<br><br>import (<br> &quot;context&quot;<br> &quot;database/sql&quot;<br> &quot;fmt&quot;<br> &quot;log&quot;<br> &quot;net/http&quot;<br> &quot;os&quot;<br> &quot;os/signal&quot;<br> &quot;time&quot;<br><br> &quot;github.com/labstack/echo/v4&quot;<br> &quot;github.com/labstack/echo/v4/middleware&quot;<br> &quot;github.com/shopspring/decimal&quot;<br><br> _ &quot;github.com/lib/pq&quot;<br>)<br><br>func getEnv(key, fallback string) string {<br> if value := os.Getenv(key); value != &quot;&quot; {<br>  return value<br> }<br> return fallback<br>}<br><br>func failOnError(err error, msg string) {<br> if err != nil {<br>  fmt.Println(msg, err)<br>  os.Exit(1)<br> }<br>}<br><br>func main() {<br> ctx := context.Background()<br> dbHost := os.Getenv(&quot;DB_HOST&quot;)<br> dbPort := os.Getenv(&quot;DB_PORT&quot;)<br> dbUser := os.Getenv(&quot;DB_USER&quot;)<br> dbPassword := os.Getenv(&quot;DB_PASSWORD&quot;)<br> dbName := os.Getenv(&quot;DB_NAME&quot;)<br> dbURL := fmt.Sprintf(&quot;host=%s port=%s user=%s password=%s dbname=%s sslmode=disable&quot;, dbHost, dbPort, dbUser, dbPassword, dbName)<br><br> db, err := sql.Open(&quot;postgres&quot;, dbURL)<br> failOnError(err, &quot;failed to open database&quot;)<br> defer func() {<br>  err := db.Close()<br>  failOnError(err, &quot;failed to close database&quot;)<br> }()<br><br> h := &amp;handler{db: db}<br> e := echo.New()<br><br> e.Use(middleware.Logger())<br> e.Use(middleware.Recover())<br><br> e.GET(&quot;/&quot;, func(c echo.Context) error {<br>  return c.JSON(http.StatusOK, echo.Map{<br>   &quot;message&quot;: &quot;Hello, this is a message from Golang running on CloudRun.&quot;,<br>  })<br> })<br> e.GET(&quot;/products&quot;, h.ListProducts)<br><br> errCh := make(chan error, 1)<br> go func() {<br>  errCh &lt;- e.Start(fmt.Sprintf(&quot;:%s&quot;, getEnv(&quot;PORT&quot;, &quot;3001&quot;)))<br> }()<br><br> ctx, cancel := signal.NotifyContext(ctx, os.Kill, os.Interrupt)<br> defer cancel()<br><br> select {<br> case err := &lt;-errCh:<br>  if err != nil &amp;&amp; err != http.ErrServerClosed {<br>   log.Fatal(&quot;failed to start server&quot;)<br>  }<br>  log.Println(&quot;server shutdown gracefully&quot;)<br><br> case &lt;-ctx.Done():<br>  ctx, cancel := context.WithTimeout(ctx, time.Second*15)<br>  defer cancel()<br><br>  log.Println(&quot;shutting down server...&quot;)<br>  if err := e.Shutdown(ctx); err != nil {<br>   log.Fatal(&quot;failed to shutdown server&quot;)<br>  }<br>  log.Println(&quot;shutdown server gracefully&quot;)<br> }<br>}<br><br>type handler struct {<br> db *sql.DB<br>}<br><br>type Product struct {<br> ID        string          `json:&quot;id&quot;`<br> Name      string          `json:&quot;displayName&quot;`<br> Currency  string          `json:&quot;currency&quot;`<br> Price     decimal.Decimal `json:&quot;price&quot;`<br> Quantity  decimal.Decimal `json:&quot;quantity&quot;`<br> CreatedAt time.Time       `json:&quot;createdAt&quot;`<br> UpdatedAt time.Time       `json:&quot;updatedAt&quot;`<br>}<br><br>func (h *handler) ListProducts(c echo.Context) error {<br> products, err := listProducts(c.Request().Context(), h.db)<br> if err != nil {<br>  return err<br> }<br><br> return c.JSON(http.StatusOK, echo.Map{<br>  &quot;products&quot;: products,<br> })<br>}<br><br>func listProducts(ctx context.Context, db *sql.DB) ([]Product, error) {<br> query := `SELECT id, display_name, currency, price, qty, created_at, updated_at FROM products`<br><br> rows, err := db.QueryContext(ctx, query)<br> if err != nil {<br>  return nil, fmt.Errorf(&quot;db.QueryContext(): %w&quot;, err)<br> }<br><br> products := make([]Product, 0)<br> for rows.Next() {<br>  var p Product<br>  if err := rows.Scan(&amp;p.ID, &amp;p.Name, &amp;p.Currency, &amp;p.Price, &amp;p.Quantity, &amp;p.CreatedAt, &amp;p.UpdatedAt); err != nil {<br>   return nil, fmt.Errorf(&quot;rows.Scan(): %w&quot;, err)<br>  }<br>  products = append(products, p)<br> }<br> return products, nil<br>}</pre><p>2. file Dockerfile</p><pre># Start from golang base image as building stage<br>FROM golang:1.19-alpine as builder<br><br># Set necessary environment variables needed for our image<br>ENV GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64<br><br># Set the current working directory inside the container<br>WORKDIR /build<br><br># Copy and download dependency using go mod<br>COPY go.mod .<br>COPY go.sum .<br>RUN apk add --no-cache ca-certificates git tzdata &amp;&amp; \<br>  go mod tidy<br><br># Copy the code into the container<br>COPY . .<br><br># Build the Go application<br>RUN go build -ldflags &quot;-s -w -extldflags &#39;-static&#39;&quot; -installsuffix cgo -o /bin/service main.go<br><br># Use alpine image as runtime<br>FROM alpine:3.16 as release<br><br>COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo<br>COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/<br>COPY --from=builder /bin/service /bin/service<br><br># Command to run <br>ENTRYPOINT [&quot;/bin/service&quot;]</pre><p>3. Build Golang API ດ້ວຍ Docker ເພື່ອກຽມ Deploy to Google Cloud Run (ສາມາດເບິ່ງລາຍລະອຽດຂອງການ build ໄດ້ທີ່ <a href="https://medium.com/laoitdev/gcp-cloud-run-%E0%BA%A1%E0%BA%B2%E0%BA%A5%E0%BA%AD%E0%BA%87-hello-choco-%E0%BA%94%E0%BB%89%E0%BA%A7%E0%BA%8D-cloud-run-%E0%BA%81%E0%BA%B1%E0%BA%99%E0%BB%80%E0%BA%96%E0%BA%B2%E0%BA%B0-2af8f956a806#3f60">ບົດຄວາມກ່ອນຫນ້ານີ້</a>)</p><pre><br>docker build -t asia-southeast1-docker.pkg.dev/phuangpheth/hal0kiity/api:v1.0.0 .</pre><p>4. Push Docker Image to Google Cloud Artifact Registory</p><pre><br>docker push asia-southeast1-docker.pkg.dev/phuangpheth/hal0kiity/api:v1.0.0</pre><h3># Deploy Golang API to Google Cloud Run</h3><ol><li>ເປີດ <a href="https://console.cloud.google.com/run"><strong>Google Cloud Console</strong></a> ແລ້ວໄປທີ່ເມນູ <strong>Cloud Run</strong></li><li>ກົດທີ່ຊື່ຂອງ <strong>service</strong> ທີ່ຈະໃຊ້ <strong>deploy (</strong>ສາມາດເບິ່ງຂັ້ນຕອນລະອຽດໄດ້ຈາກ <a href="https://medium.com/laoitdev/gcp-cloud-run-%E0%BA%A1%E0%BA%B2%E0%BA%A5%E0%BA%AD%E0%BA%87-hello-choco-%E0%BA%94%E0%BB%89%E0%BA%A7%E0%BA%8D-cloud-run-%E0%BA%81%E0%BA%B1%E0%BA%99%E0%BB%80%E0%BA%96%E0%BA%B2%E0%BA%B0-2af8f956a806#10e5">ບົດຄວາມກ່ອນຫນ້ານີ້</a><strong>)</strong></li><li>ກົດປຸ່ມ “<strong>Edit &amp; Deploy Revision</strong>”</li><li>ສຳຫລັບ Container Image ໃຫ້ກົດ “Select” ເພື່ອເລືອກ Container Image ທີ່ຈະໃຊ້ deploy</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*Gi4PBHrtri2EfuNbyShqnQ.png" /></figure><p>ເມື່ອເລືອກ Container Image ທີ່ຕ້ອງການແລ້ວໃຫ້ກົດ “Select”</p><p>5. ເພີ່ມ Environment Variables ຕາມທີ່ໄດ້ກຳນົດໄວ້ໃນ API ທີ່ສ້າງ ກໍຈະເປັນ environment ຂອງການ connect ໄປຫາ database ນັ້ນເອງ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*HR8xc02Jg2onAlRO6vV-EQ.png" /></figure><ul><li><strong>DB_HOST</strong> ແມ່ນເອົາຈາກ <strong>Cloud SQL instance</strong> ໂດຍເຂົ້າໄປທີ່ເມນູ “<strong>SQL</strong>” ແລ້ວກົດເລືອກ<strong> instance name</strong> ທີ່ຕ້ອງການ ໃນຫນ້າ <strong>Overview</strong> ຈະເຫັນ ສ່ວນຂອງ “<strong>Connect to instance</strong>” ໃຫ້ກົດ copy ເອົາ “<strong>Connection name</strong>”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*GBr6_2mxBx-RnF5Feanyyg.png" /></figure><p>ເມື່ອໄດ້ <strong>connection name</strong> ມາແລ້ວໃຫ້ເອົາມາຕໍ່ກັບ “<strong>/cloudsql/{connectionName}</strong>” ຈະໄດ້ DB_HOST ດັ່ງນີ້</p><blockquote><strong>/cloudsql/phuangpheth:asia-southeast1:choco</strong></blockquote><ul><li>ສຳຫລັບ<strong> DB_PASSWORD </strong>ຈະຕັ້ງເປັນ <strong>Secrets</strong> ເພື່ອປ້ອງການບໍ່ໃຫ້ທຸກສາມາດເຫັນ Password ນີ້ໄດ້</li></ul><p>6. ເລືອກ Cloud SQL instance ໃຫ້ກັບ Cloud SQL connections ເພື່ອໃຫ້ Cloud Run ສາມາດ connect ໄປຫາໄດ້</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*V0WNKexyffkI4m_0Zge1NQ.png" /></figure><p>7. ເມື່ອສຳເລັດກົດ “Deploy”</p><p>ຫລັງຈາກ Deploy ສຳເລັດເຮົາກໍຈະໄດ້ URL ສຳຫລັບ API ຂອງເຮົາກັນແລ້ວ.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*GLnNxs6mN82FCQ350ASYyg.png" /></figure><p>ລອງ Request ໄປຫາ API ຂອງເຮົາລອງເບິ່ງວ່າມັນຈະ Work ຫລືບໍ່</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fo2hb_dRWcF9bRCQF928FQ.png" /></figure><p>ເຢ້ໆ It is working well…… ຈົບແລ້ວໄດ໋ 555555</p><p>Support by:</p><p><a href="https://laoitdev.com/">Home - Lao IT Dev</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=844973b4d9ea" width="1" height="1" alt=""><hr><p><a href="https://medium.com/laoitdev/gcp-cloud-sql-connect-to-cloud-sql-for-postgresql-from-cloud-run-844973b4d9ea">[GCP Cloud SQL] Connect to Cloud SQL for PostgreSQL from Cloud Run</a> was originally published in <a href="https://medium.com/laoitdev">LaoITDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[GCP Cloud Run] ມາລອງ Hello CHOCO ດ້ວຍ Cloud Run ກັນເຖາະ]]></title>
            <link>https://medium.com/laoitdev/gcp-cloud-run-%E0%BA%A1%E0%BA%B2%E0%BA%A5%E0%BA%AD%E0%BA%87-hello-choco-%E0%BA%94%E0%BB%89%E0%BA%A7%E0%BA%8D-cloud-run-%E0%BA%81%E0%BA%B1%E0%BA%99%E0%BB%80%E0%BA%96%E0%BA%B2%E0%BA%B0-2af8f956a806?source=rss-27d932b42a6e------2</link>
            <guid isPermaLink="false">https://medium.com/p/2af8f956a806</guid>
            <category><![CDATA[backenddev]]></category>
            <dc:creator><![CDATA[Pao Phouminith]]></dc:creator>
            <pubDate>Sun, 19 Feb 2023 02:41:15 GMT</pubDate>
            <atom:updated>2023-03-05T12:00:33.152Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gXYhyZCasp_05p27pXvhVw.jpeg" /><figcaption>Her name is CHOCO</figcaption></figure><p>ບົດຄວາມນີ້ຈະແນະນຳຂັ້ນຕອນການ Deploy API To Google Cloud Run. ຈະໃຊ້ພາສາ Go ສຳຫລັບຂຽນ API Hello CHOCO. (source code <a href="https://gitlab.com/phuangpheth.litd/halokitty/-/tree/main/cloudrun">here</a>)</p><h3>What is Cloud Run? (ແບບສັ້ນໆ)</h3><blockquote>Cloud Run is a managed compute platform that enables you to run containers that are invocable via requests or events. Cloud Run is serverless: it abstracts away all infrastructure management, so you can focus on what matters most — building great applications. (<a href="https://cloud.google.com/run/docs">reference</a>)</blockquote><p>Cloud Run ເປັນ compute platform ແບບ Serverless ທີ່ Auto scaling Up-Down ໄດ້ຕາມຈຳນວນ Traffic ທີ່ເຂົ້າ Service ນັ້ນໆ. ເຊິ່ງແນ່ນອນການທີ່ Auto scaling Up-Down ແບບນີ້ໄດ້ Service ທີ່ເຮົາຈະເອົາຂື້ນໄປ Run ກໍຕ້ອງໄດ້ອອກແບບໃຫ້ເປັນ Stateless ຄືກັນ.</p><h3>ຂັ້ນຕອນ</h3><h4>ຂັ້ນຕອນທີ 1: ສ້າງ Project ດ້ວຍ Google Cloud Console</h4><ul><li>ເຂົ້າໄປທີ່ Google Cloud Console (console.cloud.google.com) ແລະ ລົງຊື່ເຂົ້າໃຊ້(ຖ້າຫາກຜູ້ໃຊ້ຍັງບໍ່ມີບັນຊີແມ່ນສາມາດສ້າງບັນຊີເຂົ້າໃຊ້ງານໄດ້ເລີຍ).</li><li>ຢູ່ສ່ວນເທິງຂອງເມນູໃຫ້ກົດທີ່ເມນູ project drop-down</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*33zvuDqVSAx0ts7tXxauuQ.png" /></figure><ul><li>ແລ້ວເລືອກ “<strong>NEW PROJECT</strong>”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*hbQs2Bu0YWR-pnZxwOCkpg.png" /></figure><ul><li>ເມື່ອກົດປຸ່ມ “<strong>NEW</strong> <strong>PROJECT” </strong>ຈະໄດ້ຫນ້າສຳຫລັບການສ້າງ project</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*6FG-SNzaqmJfIiF0MO6zDw.png" /></figure><p><strong>Project Name</strong> ແມ່ນຊື່ຂອງ project ທີ່ຈະໃຊ້ (ເຮົາສາມາດກຳນົດ Project ID ເອງໄດ້ ແຕ່ຈະບໍ່ສາມາດປ່ຽນໄດ້ຫລັງຈາກ project ນັ້ນຖືກສ້າງ).</p><blockquote><strong>Note:</strong> <strong>Project ID</strong> ຈະຕ້ອງເປັນ Unique ບໍ່ສາມາດຊ້ຳກັບຂອງຄົນອື່ນໄດ້.</blockquote><p>ບາງ Account ຈະມີ <strong>Billing Account</strong> ມາໃຫ້ເລືອກໃນຕອນທີ່ສ້າງ project. ສາມາດເລືອກ Billing Account ທີ່ເຮົາຈະເປີດໄວ້ກັບ project ນັ້ນໄດ້ເລີຍ ແຕ່ຖ້າຍັງບໍ່ມີ Billing Account ກໍສາມາດກົດສ້າງໄດ້.</p><p><strong>Location </strong>ເປັນ Parent organization ຫລື folder ທີ່ project ຈະຖືກສ້າງຂື້ນໃນນັ້ນ. ໃນບົດຄວາມນີ້ຈະເລືອກເປັນ No organization.</p><ul><li>ເມື່ອປ້ອນຂໍ້ມູນຄົບແລ້ວກໍກົດປຸ່ມ “<strong>Create”</strong></li></ul><blockquote>ຫລັງຈາກທີ່ເຮົາສ້າງ proejct ແລະ ເປີດ billing account ແລ້ວກໍໄປຕໍ່ທີ່ຂັ້ນຕອນຕໍ່ໄປກັນເລີຍ</blockquote><h4>ຂັ້ນຕອນທີ 2: ສ້າງ Repository ຢູ່ Artifact Registry</h4><p><strong>Artifact Registry</strong> ແມ່ນຫຍັງ?</p><blockquote>ມັນແມ່ນບ່ອນຈັດເກັບ ແລະ ຈັດການ Container Image ຫລື Software Package ໃນ Registry. ໂດຍທົ່ວໄປແລ້ວ <strong>Container Images</strong> ຈະໃຊ້ເພື່ອເຮັດ package ແລະ deploy application ໃນຮູບແບບຂອງ Containerized Enviroment. ສຳຫລັບສ່ວນຂອງ <strong>Software Packages</strong> ຈະໃຊ້ເພື່ອ distribute ແລະ install Software Dependencies.</blockquote><p>ເຮົາມາເລີ່ມຕົ້ນສ້າງ Repository ກັນດີກວ່າ</p><ul><li>ເລີ່ມຈາກກົດເລືອກຫາເມນູທີ່ຊື່ວ່າ <strong>“Artifact Registry” </strong>ເຊິ່ງມັນຈະຢູ່ໃນ section ຂອງ CI/CD</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/224/1*DQGAtX0u5BzYZ7P9mwOjQw.png" /></figure><ul><li>ກົດ “Create Repository”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uYHz2Dh1TB_hw7DGN_IzmQ.png" /></figure><ul><li>Congifure Repository ທີ່ເຮົາຈະສ້າງເຊັ່ນຊື່, Format, Mode, Location type ແລະ Encryption</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ti3RVbtftG7GQkgPRPbpWg.png" /></figure><p>ໃນບົດຄວາມນີ້ຜູ້ຂຽນຈະຕັ້ງຊື່ Repository ວ່າ hal0kitty ແລະ ມີ format ເປັນ docker. (ເຮົາສະໃຊ້ docker ໃນການ build container image)</p><ul><li>ກົດ “<strong>Create</strong>” ເພື່ອສ້າງ Repo.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t-FlmuxZFIAV9u2tRDH13g.png" /></figure><p>ຫລັງຈາກທີ່ສ້າງສຳເລັດກໍຈະໄດ້ Repo ເປົ່າໆດັ່ງຮູບພາບດ້ານເທິງ.</p><blockquote>ກໍຖືວ່າສຳເລັດສຳຫລັບການສ້າງ Repo ເພື່ອໄວ້ເກັບ Container Images ທີ່ເຮົາຈະໃຊ້ສຳຫລັບການ deploy ຂັ້ນຕອນຕໍ່ໄປຈະເປັນການ build container image ດ້ວຍ docker.</blockquote><h4>ຂັ້ນຕອນທີ 3: Build Container Image ດ້ວຍ Docker</h4><p>ກ່ອນທີ່ເຮົາຈະ build ເຮົາກໍຕ້ອງມາສ້າງ API ຂອງເຮົາຂື້ນມາກ່ອນ ຜູ້ຂຽນຈະໃຊ້ Golang ສຳຫລັບສ້າງ API Hello CHOCO.</p><ul><li>ເລີ່ມສ້າງ Go project ໂດຍ “go mod init hallochoco”</li><li>ແລ້ວກໍສ້າງ file ທີ່ມີຊື່ວ່າ main.go ເຊິ່ງພາຍໃນ file ຈະປະກອບໄປດ້ວຍ code ລຸ່ມນີ້:</li></ul><pre>package main<br><br>import (<br> &quot;context&quot;<br> &quot;fmt&quot;<br> &quot;log&quot;<br> &quot;net/http&quot;<br> &quot;os&quot;<br> &quot;os/signal&quot;<br> &quot;time&quot;<br><br> &quot;github.com/labstack/echo/v4&quot;<br> &quot;github.com/labstack/echo/v4/middleware&quot;<br>)<br><br>func getEnv(key, fallback string) string {<br> if value := os.Getenv(key); value != &quot;&quot; {<br>  return value<br> }<br> return fallback<br>}<br><br>func main() {<br> ctx := context.Background()<br> e := echo.New()<br><br> e.Use(middleware.Logger())<br> e.Use(middleware.Recover())<br><br> e.GET(&quot;/&quot;, func(c echo.Context) error {<br>  return c.JSON(http.StatusOK, echo.Map{<br>   &quot;message&quot;: &quot;Hello CHOCO, this is a message from Golang running on CloudRun.&quot;,<br>  })<br> })<br><br> errCh := make(chan error, 1)<br> go func() {<br>  errCh &lt;- e.Start(fmt.Sprintf(&quot;:%s&quot;, getEnv(&quot;PORT&quot;, &quot;3001&quot;)))<br> }()<br><br> ctx, cancel := signal.NotifyContext(ctx, os.Kill, os.Interrupt)<br> defer cancel()<br><br> select {<br> case err := &lt;-errCh:<br>  if err != nil &amp;&amp; err != http.ErrServerClosed {<br>   log.Fatal(&quot;failed to start server&quot;)<br>  }<br>  log.Println(&quot;server shutdown gracefully&quot;)<br><br> case &lt;-ctx.Done():<br>  ctx, cancel := context.WithTimeout(ctx, time.Second*15)<br>  defer cancel()<br><br>  log.Println(&quot;shutting down server...&quot;)<br>  if err := e.Shutdown(ctx); err != nil {<br>   log.Fatal(&quot;failed to shutdown server&quot;)<br>  }<br>  log.Println(&quot;shutdown server gracefully&quot;)<br> }<br>}</pre><p>ເຮົາຈະສ້າງ API ໃຫ້ໄດ້ Response ຕາມຕົວຢ່າງລຸ່ມນີ້ເມື່ອມີຄົນ Request ເຂົ້າມາທີ່ API.</p><pre>{<br>&quot;message&quot;: &quot;Hello CHOCO, this is a message from Golang running on CloudRun.&quot;<br>}</pre><ul><li>ສ້າງ Dockerfile</li></ul><pre># Start from golang base image as building stage<br>FROM golang:1.19-alpine as builder<br><br># Set necessary environment variables needed for our image<br>ENV GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64<br><br># Set the current working directory inside the container<br>WORKDIR /build<br><br># Copy and download dependency using go mod<br>COPY go.mod .<br>COPY go.sum .<br>RUN apk add --no-cache ca-certificates git tzdata &amp;&amp; \<br>  go mod tidy<br><br># Copy the code into the container<br>COPY . .<br><br># Build the Go application<br>RUN go build -ldflags &quot;-s -w -extldflags &#39;-static&#39;&quot; -installsuffix cgo -o /bin/service main.go<br><br># Use alpine image as runtime<br>FROM alpine:3.16 as release<br><br>COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo<br>COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/<br>COPY --from=builder /bin/service /bin/service<br><br># Command to run <br>ENTRYPOINT [&quot;/bin/service&quot;]%</pre><ul><li>ສັ່ງ build container image</li></ul><pre>docker build -t {region}-docker.pkg.dev/{projectName}/{repositoryName}/{imageName}:{tag} .</pre><blockquote><strong>- region </strong>ຈະຂື້ນກັບ Location type ທີ່ເຮົາເລືອກຕອນສ້າງ Repo <strong><br>- projectName</strong> ແມ່ນຊື່ຂອງ project ທີ່ເຮົາສ້າງໄວ້ຢູ່ Google Cloud<br><strong>- repositoryName</strong> ແມ່ນຊື່ຂອງ Repo ທີ່ເຮົາສ້າງໄວ້ໃນ Artifact Registry<br>- <strong>imageName</strong> ແມ່ນຊື່ image ທີ່ເຮົາຈະຕັ້ງໃຫ້<br>- <strong>tag</strong> ແມ່ນ tag ທີ່ເຮົາຈະລະບຸໃຫ້ກັບ image ຕົວດັ່ງກ່າວເຊັ່ນ ເລກເວີເຊິນຂອງ image</blockquote><p>ເຮົາສາມາດເຂົ້າໄປເອົາຂື້ນມູນສ່ວນນີ້ໄດ້ຈາກ Repo ທີ່ເຮົາສ້າງໄວ້ໄດ້ເລີຍ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/423/1*KV8M1laXdEpWD2j_3vj-Hg.png" /></figure><p>ພຽງແຕ່ເຮົາກົດ “Copy” ເຮົາກໍຈະໄດ້ຂໍ້ມູນສ່ວນດັ່ງກ່າວ</p><blockquote>ຄຳສັ່ງຂອງຜູ້ຂຽນກໍຈະໄດ້ອອກມາດັ່ງນີ້:</blockquote><pre>docker build -t asia-southeast1-docker.pkg.dev/phuangpheth/hal0kiity/api:v1.0.0 .</pre><p>ເມື່ອກົດ Enter ຂະບວນການ build ກໍຈະດຳເນີນ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*ehX84-Ct5ECdGTctdjkn9w.png" /></figure><p>ຫລັງຈາກ build ສຳເລັດເຮົາກໍຈະໄດ້ image ຕົວຫນຶ່ງທີ່ເຮົາຈະໃຊ້ push ຂື້ນໄປ repo ຂອງເຮົາ.</p><ul><li>Push container image ຂື້ນ Artifact Registry</li></ul><pre>docker push {region}-docker.pkg.dev/{projectName}/{repositoryName}/{imageName}:{tag}</pre><p>ກໍລະນີທີ່ເກີດ error ບໍ່ສາມາດ push ຂື້ນ Repo ທີ່ສ້າງໄວ້ໄດ້ທີ່ເປັນ error permission denied ຫລື It may not exist ອາດຈະເປັນຍ້ອນເຮົາຍັງບໍ່ໄດ້ config auth. ສາມາດໃຊ້ຄຳສັ່ງລຸ່ມນີ້ເພື່ອແກ້ໄຂ</p><pre>gcloud auth configure-docker \                                             <br>    {region}-docker.pkg.dev</pre><p>ສຳຫລັບ region ແມ່ນໃຫ້ໃສ່ຕາມທີ່ເຮົາເລືອກໄວ້ໃນຕອນທີ່ເຮົາສ້າງ Repository.</p><blockquote>ຄຳສັ່ງຂອງຜູ້ຂຽນກໍຈະໄດ້ອອກມາດັ່ງນີ້:</blockquote><pre>docker push asia-southeast1-docker.pkg.dev/phuangpheth/hal0kiity/api:v1.0.0 </pre><p>ເມື່ອກົດ push ສຳເລັດກໍໄດ້ດັ່ງນີ້:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*QiUe3lzxPBhwcu1UlyoeCw.png" /></figure><p>ຫລັງຈາກ push ຂື້ນສຳເລັດເຮົາມາກວດເບິ່ງ Repo ຂອງເຮົາຢູ່ Google Cloud Console ເຮົາກໍເຫັນ Image ທີ່ເຮົາໄດ້ push ຂື້ນ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pb8K9FPPB4UgG3dS12scGQ.png" /></figure><p>ແລະ ເມື່ອກົດໃສ່ Image ເຮົາກໍໄດ້ຫນ້າສະແດງລາຍລະອຽດຂອງ image ຕົວດັ່ງກ່າວ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nRCBrw9KyTGKTTBz-8I-jg.png" /></figure><p>ເຊິ່ງໃນລາຍລະອຽດຈະສະແດງວ່າ image ຂອງເຮົານັ້ນມີ tags ຫຍັງແດ່(ຕາມທີ່ເຮົາໄດ້ກຳນົດໄວ້ໃນຕອນ build).</p><p>ມາຮອດຈຸດນີ້ກໍຖືກວ່າຕົວ API ຂອງເຮົາແມ່ນພ້ອມແລ້ວສຳຫລັບການ deploy.</p><h4>ຂັ້ນຕອນທີ 4: Deploy Hello CHOCO API to Cloud Run</h4><ul><li>ເລີ່ມຈາກກົດທີ່ເມນູແລ້ວເລືອກຫາເມນູທີ່ຊື່ວ່າ <strong>“Cloud Run”</strong></li><li>ກົດ “Create Service”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0gtF66Y-bfMas_dpIkBtJA.png" /></figure><ul><li>ຈະໄດ້ຫນ້າສຳຫລັບ configure</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*51Mp5qPMPYlIQVdLdr79uQ.png" /></figure><ol><li>ເລືອກ Container Image ກົດ “SELECT”</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*Ge4fEx7ni9n_NU2TG50YgQ.png" /></figure><p>ໃຫ້ເຮົາເລືອກ container image ທີ່ເຮົາຈະໃຊ້ແລ້ວກົດ “SELECT”.</p><p>2. ຕັ້ງຊື່ service</p><p>3. ເລືອກ region ທີ່ເຮົາຈະໃຊ້</p><p>4. CPU Allocation and pricing ຈະມີ 2 ຕົວເລືອກໃຫ້ເລືອກລະຫວ່າງ</p><ul><li>CPU is only allocated during request processing: ເມື່ອມີຄົນເຂົ້າໃຊ້ຈຶ່ງເປີດ</li><li>CPU is always allocated: ເປີດໄວ້ຕະຫລອດເວລາຕໍ່ໃຫ້ບໍ່ມີຄົນໃຊ້ກໍຕາມ</li></ul><p>5. Autoscaling ການກຳນົດ scaling ຂອງ service ວ່າຈະໃຫ້ scale ໄດ້ສູງສຸດເທົ່າໃດ ແລະ ຕ່ຳສຸດເທົ່າໃດ</p><p>6. Authentication ເປັນການກຳນົດວ່າເຮົາຕ້ອງການໃຫ້ມີ Authen ຫລືບໍ່ເມື່ອມີຄົນຕ້ອງການເອີ້ນໃຊ້ service ຂອງເຮົາ.</p><p>7. ການ configure Container, Networking, Security</p><ul><li>ສ່ວນຂອງ Container ເຮົາສາມາດກໍນົດຄ່າຂອງ: <em>PORT</em> ທີ່ຈະໃຊ້ run, <em>Memory</em>, <em>CPU, Request timeout, Max request per container, Excution environment, environment variables, secret environment variables</em>, Health checks ແລະ Cloud SQL connections.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*PEvs2wk2RxhvrqmxVAfgcg.png" /></figure><ul><li>ສ່ວນຂອງ Networking (ສ່ວນນີ້ແມ່ນເຮົາຈະຍັງບໍ່ໄດ້ config ຫຍັງຈະໃຊ້ default)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*SIse5I97wA8VZvcD_mzTeA.png" /></figure><ul><li>ສ່ວນຂອງ Security (ສ່ວນນີ້ແມ່ນເຮົາຈະຍັງບໍ່ໄດ້ config ຫຍັງຈະໃຊ້ default)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*vjD-qw-I6lsl1VZRov72HA.png" /></figure><p>ຫລັງຈາກທີ່ເຮົາກຳນົດຄ່າຕ່າງໆຂອງ Service ເຮົາແລ້ວກົດ “<strong>CREATE</strong>”</p><p>ເມື່ອ service ຂອງເຮົາສ້າງສຳເລັດຈະໄດ້ດັ່ງນີ້</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S7gYw73XVCoh0WgNTOFO2A.png" /></figure><p>ເຮົາສາມາດ copy ເອົາ URL ຂອງ service ທີ່ເຮົາ deploy ໄປທົດສອບໄດ້ເລີຍ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*qUIVsZ1z-ICDOfArmuL8uA.png" /></figure><p>ເມື່ອເຮົາທົດສອບ Request ໄປຫາ API ທີ່ເຮົາ deploy ໄວ້ເຮົາກໍຈະໄດ້</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uUdFzvuUBkbLer7PJZcchQ.png" /></figure><p>ເຢ້ໆ message ທີ່ຕອບກັບມາຄືກັນທີ່ເຮົາຄາດຫວັງໄວ້ເລີຍຍຍຍ</p><p>ມາຮອດນີ້ກໍຈະຖືວ່າສຳເລັດແລ້ວສຳເລັດການ deploy API Hello CHOCO. ແລ້ວກໍລະນີທີ່ເຮົາຈະອັບເດດ API ເຮົາເດ ເຮົາຈະຕ້ອງໄດ້ເຮັດແນວໃດ ຂັ້ນຕອນຕໍ່ໄປເຮົາຈະມາອັບເດດ API ຂອງເຮົາໃຫ້ມີ Endpoint ສຳຫລັບ List ລາຍການສິນຄ້າອອກມາສະແດງ.</p><h4>ຂັ້ນຕອນທີ 5: Update Hello CHOCO API ໃຫ້ມີ List Products</h4><ol><li>ເພີ່ມ code ສ່ວນ List Products ໃສ່ file main.go</li></ol><pre>package main<br><br>import (<br> &quot;context&quot;<br> &quot;fmt&quot;<br> &quot;log&quot;<br> &quot;net/http&quot;<br> &quot;os&quot;<br> &quot;os/signal&quot;<br> &quot;time&quot;<br><br> &quot;github.com/google/uuid&quot;<br> &quot;github.com/labstack/echo/v4&quot;<br> &quot;github.com/labstack/echo/v4/middleware&quot;<br> &quot;github.com/shopspring/decimal&quot;<br>)<br><br>func getEnv(key, fallback string) string {<br> if value := os.Getenv(key); value != &quot;&quot; {<br>  return value<br> }<br> return fallback<br>}<br><br>func main() {<br> ctx := context.Background()<br> e := echo.New()<br><br> e.Use(middleware.Logger())<br> e.Use(middleware.Recover())<br><br> e.GET(&quot;/&quot;, func(c echo.Context) error {<br>  return c.JSON(http.StatusOK, echo.Map{<br>   &quot;message&quot;: &quot;Hello CHOCO, this is a message from Golang running on CloudRun.&quot;,<br>  })<br> })<br> e.GET(&quot;/products&quot;, listProducts)<br><br> errCh := make(chan error, 1)<br> go func() {<br>  errCh &lt;- e.Start(fmt.Sprintf(&quot;:%s&quot;, getEnv(&quot;PORT&quot;, &quot;3001&quot;)))<br> }()<br><br> ctx, cancel := signal.NotifyContext(ctx, os.Kill, os.Interrupt)<br> defer cancel()<br><br> select {<br> case err := &lt;-errCh:<br>  if err != nil &amp;&amp; err != http.ErrServerClosed {<br>   log.Fatal(&quot;failed to start server&quot;)<br>  }<br>  log.Println(&quot;server shutdown gracefully&quot;)<br><br> case &lt;-ctx.Done():<br>  ctx, cancel := context.WithTimeout(ctx, time.Second*15)<br>  defer cancel()<br><br>  log.Println(&quot;shutting down server...&quot;)<br>  if err := e.Shutdown(ctx); err != nil {<br>   log.Fatal(&quot;failed to shutdown server&quot;)<br>  }<br>  log.Println(&quot;shutdown server gracefully&quot;)<br> }<br>}<br><br>type Product struct {<br> ID        string          `json:&quot;product&quot;`<br> Name      string          `json:&quot;name&quot;`<br> Currency  string          `json:&quot;currency&quot;`<br> Price     decimal.Decimal `json:&quot;price&quot;`<br> Quantity  decimal.Decimal `json:&quot;quantity&quot;`<br> CreatedAt time.Time       `json:&quot;createdAt&quot;`<br> UpdatedAt time.Time       `json:&quot;updatedAt&quot;`<br>}<br><br>func listProducts(c echo.Context) error {<br> products := make([]Product, 0)<br> products = append(products, Product{<br>  ID:        uuid.NewString(),<br>  Name:      &quot;Apple iPhone 14 Pro Max&quot;,<br>  Currency:  &quot;LAK&quot;,<br>  Price:     decimal.NewFromInt(25240000),<br>  Quantity:  decimal.NewFromInt(50),<br>  CreatedAt: time.Now(),<br>  UpdatedAt: time.Now(),<br> })<br><br> products = append(products, Product{<br>  ID:        uuid.NewString(),<br>  Name:      &quot;Apple MacBook Pro M2 (Chip M2 Pro)&quot;,<br>  Currency:  &quot;LAK&quot;,<br>  Price:     decimal.NewFromInt(65200000),<br>  Quantity:  decimal.NewFromInt(15),<br>  CreatedAt: time.Now(),<br>  UpdatedAt: time.Now(),<br> })<br> return c.JSON(http.StatusOK, echo.Map{<br>  &quot;products&quot;: products,<br> })<br>}</pre><p>2. Build Container Image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HMMBuGLC4KP7X41LDutc1w.png" /></figure><p>3. Push Container Image to Artifact Registry Repo</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*k8eQ356alHCy0AL5ZOuafg.png" /></figure><p>4. Edit &amp; Deploy New Revision</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*szBYWVOA9LPixQWDLhZSEQ.png" /></figure><p>ເຂົ້າໄປທີ່ເມນູ Cloud Run ແລ້ວກົດ “Edit &amp; Deploy New Revision”.</p><p>ໃນສ່ວນຂອງຫນ້າແກ້ໄຂໃຫ້ປ່ຽນ Container Image ທີ່ເຮົາຈະໃຊ້</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*4uqZvFezRI8uyThiRx66DQ.png" /></figure><ul><li>ກົດ “SELECT”</li><li>ເລືອກ Container Image ທີ່ເຮົາຈະ Deploy</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*yuew4KWw-LdD7PQRVXrs7Q.png" /></figure><ul><li>ເມື່ອເລືອກສຳເລັດກົດ “SELECT”</li><li>ກົດ “Deploy” ຖ້າໃຫ້ Service Deploy ສຳເລັດ</li></ul><p>ຫລັງຈາກ Deploy ສຳເລັດເຮົາທົດສອບ Endpoint ທີ່ເຮົາເພີ່ມເຂົ້າໄປໃຫມ່ວ່າມັນອັບເດດໃຫ້ເຮົາແທ້ບໍ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FTOkr7NSGKELxbgZkleRew.png" /></figure><p>ເຢ້ໆ It’s working well.</p><h3>Conclusion</h3><p>ຖ້າມີຂໍ້ຜິດພາດປະການໃດ ຫລື ມີສິ່ງໃດຢາກນຳແນະກໍແນະນຳໄດ້ເດີ້ ຜູ້ຂຽນເອງກໍກຳລັງຮຽນໃຊ້ຢູ່ຄືກັນ 5555 ສາມາດແລກປ່ຽນກັນໄດ້</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2af8f956a806" width="1" height="1" alt=""><hr><p><a href="https://medium.com/laoitdev/gcp-cloud-run-%E0%BA%A1%E0%BA%B2%E0%BA%A5%E0%BA%AD%E0%BA%87-hello-choco-%E0%BA%94%E0%BB%89%E0%BA%A7%E0%BA%8D-cloud-run-%E0%BA%81%E0%BA%B1%E0%BA%99%E0%BB%80%E0%BA%96%E0%BA%B2%E0%BA%B0-2af8f956a806">[GCP Cloud Run] ມາລອງ Hello CHOCO ດ້ວຍ Cloud Run ກັນເຖາະ</a> was originally published in <a href="https://medium.com/laoitdev">LaoITDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ICTERROR#ປະສົບການການຝຶກງານທີ່ບໍລິສັດ LAOITDEV]]></title>
            <link>https://p40pmn.medium.com/icterror-%E0%BA%9B%E0%BA%B0%E0%BA%AA%E0%BA%BB%E0%BA%9A%E0%BA%81%E0%BA%B2%E0%BA%99%E0%BA%81%E0%BA%B2%E0%BA%99%E0%BA%9D%E0%BA%B6%E0%BA%81%E0%BA%87%E0%BA%B2%E0%BA%99%E0%BA%97%E0%BA%B5%E0%BB%88%E0%BA%9A%E0%BB%8D%E0%BA%A5%E0%BA%B4%E0%BA%AA%E0%BA%B1%E0%BA%94-laoitdev-a9d9155e89a6?source=rss-27d932b42a6e------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9d9155e89a6</guid>
            <dc:creator><![CDATA[Pao Phouminith]]></dc:creator>
            <pubDate>Sat, 19 Oct 2019 13:29:39 GMT</pubDate>
            <atom:updated>2019-10-24T04:07:36.122Z</atom:updated>
            <content:encoded><![CDATA[<p>ການຝຶກງານນັ້ນເປັນປະສົບປະການອັນຫນຶ່ງທີ່ນັກສຶກສາຈະຕ້ອງໄດ້ປະເຊີນ ເມື່ອວັນ ແລະ ເວລາອັນເໝາະສົມມາຮອດ ແລະ ຈອດເຖິງ.</p><p>ບົດຄວາມນີ້ແມ່ນຈະມາຂຽນກ່ຽວກັບປະສົບປະການຂອງຜູ້ຂຽນເອງ ຂະນະທີ່ລົງຝຶກງານທີ່ບໍລິສັດ ລາວ ໄອທີ ພັດທະນາ ເຊິ່ງພວກເຮົາໄດ້ລົງກັນໄປ 3 ຄົນ (ເປົາ, ກັອບ, ພັດ) ແລະ ມີນັກສຶກສາທີມາຈາກວິທະຍາໄລສຸສະກະອີກ 3 ຄົນ (ເປົ໋າ, ກະຈ໋ຽບ ,ເບີດ).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xtnzoeE5nuPTBmUj2cdWCA.jpeg" /></figure><h3>#ໄດ້ເຮັດຫຍັງແດ່ນະຕອນທີ່ຝຶກງານ</h3><p>ໃນຊ່ວງທີ່ໄດ້ລົງຝຶກງານຢູ່ ບໍລິສັດ ລາວໄອທີ ພັດທະນາ ແມ່ນເຕັມໄປດ້ວຍຄວາມມ່ວນຊື່ນ ແລະ ຄວາມບັນເທີງຕະຫລອດຂອງທັງຫມົດໃນຊ່ວງເວລາທີ່ຝຶກງານ. ເຊິ່ງກໍມີຫລາຍໆຄວາມປະທັບໃຈທີ່ໄດ້ຮັບຈາກສະຖານທີ່ນີ້ ປະກອບປະດ້ວຍ:</p><h3>#ໄດ້ຮູ້ຈັກກັບເກມ Uno</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y7kuaHHeZ-pt3MyCAHNS8Q.jpeg" /></figure><p>ຖືໄດ້ວ່າເປັນລຸ້ນທີ່ຮູ້ຈັກກັນໃນນາມຂອງ Uno ເລີຍກໍເປັນໄດ້ ຫລິ້ນກັນໄດ້ທຸກເມື່ອທີ່ມີໂອກາດ ຮະຮະຮະ.</p><h3># code not working</h3><p>ເວລາທີ່ມີປັນຫາ ຂຽນ code ລັນບໍ່ອອກ ອ້າຍໆທຸກຄົນພ້ອມຊ່ວຍສະເໝີຂໍພຽງແຕ່ເອີ້ນຫາ. ບໍ່ວ່າຈະປັນຫາອັນໃດມາອ້າຍໆເພິ່ນສາມາດແກ້ ແລະ ອະທິບາຍໃຫ້ຟັງແບບຈຸດກຳເນີດຈົນເຖິງຈຸດທີ່ສະລາຍໂຕເປັນເລີຍທີ່ດຽວ. ຈຸດນີ້ຈະເຮັດໃຫ້ເຮົາຮູ້ໄດ້ທັນທີເລີຍວ່າ ເx້ຍທີ່ຕູຮຽນມາມັນພຽງແຕ່ຫນ້ອຍດຽວອິຫຼີ 🥴🥴.</p><h3>#Activities</h3><p>ທຸກໆຕອນແລງວັນຄານຂອງອາທິດແມ່ນຈະມີການຫລິ້ນກິລາຂອງທາງບໍລິສັດ ເຊິ່ງກໍແມ່ນກິລາຕີດອກປີກໄກ່ ທາງພວກເຮົາກໍພາດບໍ່ໄດ້ທີ່ຈະເຂົ້າຮ່ວມນຳ.</p><p>#ຕີດອກເດີ້ຕີດອກ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*QPiXsch6ICmX8t0ubXFO1w.jpeg" /></figure><p>#ວຽກຕໍ່ສາຍແລນກໍມາ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pBFiDU0KEd01hTsnlSG4LA.jpeg" /></figure><p>ມີຄວາມຕັ້ງໃຈຢ່າງສູງເມື່ອໄດ້ຍິນຄຳວ່າຕໍ່ເສຍຫົວລະ 3000 ກີບ. ແລະ ຜົນງານໃນມື້ນັ້ນກໍພາກັນຈັດໄປ 10 ຫົວ ທີ່ພວກເຮົາຕໍ່ແລ້ວໃຊ້ງານບໍ່ໄດ້ ຮະຮະຮະ ເສຍຫາຍໄປຫຼາຍເຕີບ😆😆.</p><p>#ກິນເຂົ້າສາມັກຄີ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WeJU3IY3zxPUr8-zucsqIw.jpeg" /></figure><p>#ກິນເຂົ້າເດີ້ກິນເຂົ້າ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*xFXnGDqoq-A8m4IbBfwHWQ.jpeg" /></figure><h3>#Exp</h3><p>ຖືໄດ້ວ່າສ່ວນນີ້ເປັນປະສົບປະການອັນສຳຄັນທີ່ໄດ້ຮັບຈາກບໍລິສັດເລີຍກໍວ່າໄດ້ ເພາະທາງບໍລິສັດເພິ່ນໄດ້ມອບວຽກທີ່ເປັນວຽກແທ້ຂອງລູກໃຫ້ພວກເຮົາໄດ້ເຮັດ ເຊິ່ງສິ່ງນີ້ກໍໄດ້ມາທັງຄວາມກົດດັນທີ່ຢ້ານຮັບມາແລ້ວເຮັດວຽກໃຫ້ເພິ່ນບໍ່ໄດ້ ແລະ ຢ້ານເຮັດວຽກເພິ່ນເສຍຫາຍ ແຕ່ໃນທີ່ສຸດພວກເຮົາກໍຜ່ານມັນມາໄດ້ແບບວ່າອິລາກອິເລືອນກັນເລີຍທີດຽວ.</p><h3>#ສຸດທ້າຍທ້າຍສຸດ</h3><p>ທີ່ກ່າວມານັ້ນກໍເປັນພຽງແຕ່ສ່ວນຫນຶ່ງເທົ່ານັ້ນຂອງການຝຶກງານທີ່ ລາວໄອທີ ພັດທະນາ ຍັງມີອີກຫລາຍໆຢ່າງທີ່ຍັງບໍ່ໄດ້ເວົ້າເທື່ອ. ຖ້າຢາກຮູ້ວ່າເປັນຈັ່ງໃດໃຫ້ທ່ານມາພິສູດໄດ້ເລີຍ ຮັບປະກັນວ່າທ່ານຈະໄດ້ທັງຄວາມຮູ້ ແລະ ຄວາມເປັນຄອບຄົວໃນບໍລິສັດແຫ່ງນີ້.</p><p>ສຸດທ້າຍກໍຂໍຂອບໃຈມາຍັງ ບໍລິສັດ ລາວໄອທີ ພັດທະນາ ທີ່ໄດ້ມອບໂອກາດຄັ້ງນີ້ໃຫ້ກັບພວກນ້ອງ. ຂໍຂອບໃຈ😊😊😊</p><h3>#Come home</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-CeByf1bWBSk1Go1mHmzTw.jpeg" /></figure><p>ຮູບນີ້ບໍ່ກ່ຽວເປັນພຽງພາບປະກອບ(ນະຊ່ວງເວລາຂອງການຊອກຫາຮ້ານຈອດຢາງລົດ ).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9d9155e89a6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ICTERROR# Start Golang ທົດສອບ Project Hello Golang]]></title>
            <link>https://p40pmn.medium.com/icterror-start-golang-%E0%BA%97%E0%BA%BB%E0%BA%94%E0%BA%AA%E0%BA%AD%E0%BA%9A-project-hello-golang-b88ea93cd9af?source=rss-27d932b42a6e------2</link>
            <guid isPermaLink="false">https://medium.com/p/b88ea93cd9af</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[install-go]]></category>
            <dc:creator><![CDATA[Pao Phouminith]]></dc:creator>
            <pubDate>Tue, 17 Sep 2019 01:01:02 GMT</pubDate>
            <atom:updated>2019-09-17T03:41:36.658Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*GqJlIrGU0n5vEE4qGqrwnA.jpeg" /></figure><h4>#TLDR</h4><p>ຈາກທີ່ໄດ້ສຶກສາ ແລະ ຊອກອ່ານຫລາຍໆບົດຄວາມກ່ຽວກັບ Go ມາເປັນເວລາຫລາຍອາທິດມື້ນີ້ຈຶ່ງລອງຂຽນຂື້ນເອງລອງເບິ່ງເພື່ອທ້ວນຄືນສິ່ງທີ່ໄດ້ສຶກສາຜ່ານມາວ່າມີຄວາມເຂົ້າຫລາຍປານໃດ ແລະ ຈະສາມາດອະທິບາຍໃຫ້ຜູ້ອ່ານຄົນອື່ນເຂົ້າໃຈໄດ້ຫລາຍປານໃດ ຮະຮະຮະ ຕິຊົມກັນໄດ້ເດີ້ ອິອິອິ</p><h4>#ແນະນຳເບື້ອງຕົ້ນກ່ຽວກັບ GO</h4><p>GO ເປັນ Open source ທີ່ພັດທະນາຂື້ນໂດຍທີມພັດທະນາຂອງ Google , ເປັນພາສາທີ່ນິຍົມກັນຫຼາຍໃນກຸ່ມຂອງນັກພັດທະນາ API ເພາະເປັນພາສາທີໄວ (Write one run anywhere)</p><h4>#ຂັ້ນຕອນການຕິດຕັ້ງ Go</h4><p>ໃນການທີ່ຈະຂຽນ GO ຂື້ນມາແລ້ວໃຫ້ສາມາດ Run ໄດ້ນັ້ນເຮົາຕ້ອງໄດ້ຕິດຕັ້ງຕົວຂອງ GO Compiler ກ່ອນ ເຊິ່ງຈະມີຂັ້ນຕອນດັ່ງນີ້:</p><p>ໃຫ້ໄປໂຫລດເອົາ file ຕິດຕັ້ງຕາມ link ນີ້: <a href="https://golang.org/dl/">https://golang.org/dl/</a> ເຊິ່ງມັນກໍຈະມີໃຫ້ເລືອກຕາມລະບົບປະຕິບັດການທີ່ເຮົາໃຊ້. ໃນບົດຄວາມນີ້ຜູ້ຂຽນແມ່ນໄດ້ໃຊ້ ລະບົບປະຕິບັດການ Window ແລະ ເຮົາກໍຈະຕິດຕັ້ງແບບ GUI</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L_6aS3x7Q57z6iBsdH7BHQ.png" /></figure><p>ເມື່ອໂຫລດມາແລ້ວກໍພຽງແຕ່ double click ໃສ່ file ນັ້ນເລີຍເພື່ອເລີ່ມຂັ້ນຕອນການຕິດຕັ້ງ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*qqvmJPpYaQZjIkr-MvFqMA.png" /></figure><p>ເມື່ອຫນ້າຕ່າງນີ້ຂື້ນມາກໍພຽງແຕ່ກົດ next ໄປເລື່ອຍໆ ແຕ່ຈະມີຢູ່ຈຸດໜຶ່ງທີ່ມັນໃຫ້ເຮົາເລືອກ path ທີ່ເຮົາຈະຕິດຕັ້ງເພື່ອເປັນ GoRoot ນັ້ນເອງ (ການຕິດຕັ້ງກໍບໍ່ມີຫຍັງຫລາຍມີແຕ່ next ກັບ next).</p><p>ຫລັງຈາກຕິດຕັ້ງແລ້ວ ເຮົາມາກວດເບິ່ງວ່າທີ່ເຮົາໄດ້ຕິດຕັ້ງໄປນັ້ນມັນໄດ້ແທ້ບໍ່ ໂດຍການເປີດ CMD (Command Prompt) ແລ້ວໃຊ້ຄຳສັ່ງ :</p><blockquote>go version</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*lR3giVz0MftFutjG0XZOBw.png" /></figure><p>ຖ້າຜົນໄດ້ຮັບສະແດງອອກມາແບບໃນຮູບແລ້ວກະສະແດງວ່າທ່ານໄດ້ຕິດຕັ້ງສຳເລັດແລ້ວ.</p><p>ຕໍ່ໄປເຮົາສະມາກວດເບິ່ງ go environment ເພື່ອເບິ່ງວ່າ <strong>Go Root</strong> ແລະ <strong>Go path</strong> ຂອງເຮົາຢູ່ໃສ?</p><p><strong>#Go Root :</strong> ແມ່ນເປັນບ່ອນທີ່ເຮົາຕິດຕັ້ງ GO ນັ້ນເອງ ເຊິ່ງເປັນບ່ອນທີ່ເກັບ package ຕ່າງໆທີ່ built-in ມາກັບ GO ໄວ້ ເຊິ່ງເວລາທີ່ Go Compiler ເຮັດວຽກມັນຈະແລ່ນເຂົ້າມາຊອກເບິ່ງ package ຈາກຈຸດນີ້ກ່ອນວ່າມີຫຼືບໍ່ ຖ້າຫາກວ່າບໍ່ພົບມັນຈຶ່ງຈະໄປຊອກທີ່ Go Path.</p><p><strong>#Go Path : </strong>ແມ່ນເປັນບ່ອນທີ່ເຮົາຈະເກັບ file ຂອງ project ເຮົາໄວ້ນັ້ນເອງ. ເຊິ່ງຫນ້າທີ່ຫລັກກໍຄືຈັດເກັບ file project ຂອງເຮົານັ້ນເອງ ອິອິອິ.</p><p>ເຮົາຈະມາກວດເບິ່ງໂດຍການໃຊ້ຄຳສັ່ງ :</p><blockquote>go env</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*OM1ryt_w2UF4uosWc2zBdQ.png" /></figure><p>ເຊິ່ງຈະເຫັນໄດ້ວ່າ : <strong>Go Root</strong> ຂອງຜູ້ຂຽນແມ່ນຢູ່ <strong>P:\Go</strong> ກໍລະນີນີ້ແມ່ນຜູ້ຂຽນໄດ້ຕິດຕັ້ງໄວ້ໃນຊ່ອງຂອງມູນ<strong> P:\ </strong>ແລະ ​<strong>Go Path</strong> ແມ່ນຢູ່ທີ່ <strong>C:\Users\Administrator\go</strong> ໂດຍປົກກະຕິແລ້ວ <strong>Go path</strong> ແມ່ນຈະຖືກຕັ້ງຄ່າໄວ້ໃນ <strong>path</strong> ນີ້.</p><p>ເມື່ອມາຮອດຈຸດນີ້ແລ້ວ ເຮົາກໍມາເລີ່ມກັນເລີຍ ເມື່ອເຮົາຮູ້ <strong>Go path</strong> ແລ້ວເຮົາກໍເຂົ້າໄປສ້າງ <strong>New Directory</strong> ຂື້ນມາໂດຍໃຊ້ຊື່ວ່າ <strong>src </strong>ໃນ Home Directory ຂອງ Go ດ້ວຍຄຳສັ່ງ</p><blockquote>mkdir src</blockquote><p>ເມື່ອສ້າງສຳເລັດແລ້ວກໍໃຫ້ເຮົາ <strong>cd</strong> ເຂົ້າໄປຫາ <strong>src directory </strong>ຂອງເຮົາແລ້ວສ້າງ folder project ຂອງເຮົາຂື້ນມາໂດຍຜູ້ຂຽນຈະຕັ້ງຊື່ວ່າ <strong>hellogolang </strong>ດ້ວຍຄຳສັ່ງ</p><blockquote>mkdir hellogolang</blockquote><p>ເມື່ອສ້າງສຳເລັດແລ້ວ ໃຫ້ເຮົາ cd ເຂົ້າໄປຫາ hellogolang ຂອງເຮົາກັນເລີຍ ແລະ ຕອນນີ້ເຮົາຈະຢູ່ໃນ Directory ດັ່ງນີ້:</p><blockquote>C:/Users/Administrator/go/src/hellogolang</blockquote><p>ເມື່ອມາຮອດຈຸດນີ້ແລ້ວໃຫ້ເຮົາສ້າງ file ຫນຶ່ງຂື້ນມາໃນ folder hellogolang ໂດຍໃສ່ໃຫ້ຊື່ວ່າ</p><p>main.go ແລະ ພາຍໃນ file ຈະປະກອບໄປດ້ວຍ Code ຢູ່ສອງສ່ວນຄື ສ່ວນຂອງ package ແລະ ສ່ວນຂອງ function main</p><p>code ໃນ file main.go</p><pre>package main<br>func main() {<br>   println(&quot;Sabaidee Golang&quot;)<br>}</pre><p>ຫລັງຈາກທີ່ສ້າງສຳເລັດ ແລະ save file ຮຽບຮ້ອຍແລ້ວເຮົາກໍມາໃຊ້ຄຳສັ່ງເພື່ອ Run file project ຂອງເຮົາດ້ວຍຄຳສັ່ງ</p><blockquote>go run main.go</blockquote><p>ເມື່ອກົດ Enter ກໍຈະໄດ້ຜົນໄດ້ຮັບວ່າ <strong>Sabaidee Golang</strong> ດັ່ງໃນລຸ່ມນີ້</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*KYhxT_mwXF8KHqB7anzMiw.png" /></figure><p>ໄດ້ເສີຍເລີຍ ຮະຮະຮະ ກໍຈະຖືກວ່າຈົບລົງກັບການຕິດຕັ້ງ ແລະ ສ້າງ hello project ( ຈົບກັນໄປແບບງົງໆ ຮະຮະຮະ )</p><p>ຕໍ່ມາເຮົາຮຽນຮູ້ກ່ຽວກັບການສ້າງທີ່ຢູ່ເພື່ອເກັບ project ພາສາ Go ຕາມທີ່ Github ໄດ້ແນະນຳເອົາໄວ້ ເຊິ່ງການທີ່ສ້າງແບບນີ້ແມ່ນເໝາະສຳຫລັບນັກພັດທະນາທີ່ໃຊ້ Pornhub ອຸ້ຍ Github ເວົ້າຫລາຍລະ ມາເລີ່ມກັນເລີຍ</p><h4>#ການສ້າງ part ຂອງ project ໃນພາສາ Go ທີ່ Github ແນະນຳ</h4><p>ກໍຄືວ່າທີ່ຜ່ານມານັ້ນເຮົາໄດ້ສ້າງ project ຂອງເຮົາໄວ້ໃນ C:/Users/Administrator/go/src/hellogolang ເລີຍແມ່ນບໍ່ ແຕ່ວ່າຖ້າເຮົາໃຊ້ Version Control ໂດຍສະເພາະໃນ Github ເຮົາຄວນຈະສ້າງ project ໄວ້ໃນຮູບແບບດັ່ງນີ້:</p><blockquote>C:/Users/Administrator/go/src/github.com/ ຊື່ username github/ ຊື່ project</blockquote><p>ເປັນຫຍັງເຮົາຈຶ່ງສ້າງແບບນີ້ ຂໍ້ດີຂອງມັນມີຢູ່ວ່າ ເມື່ອເຮົາໄປໂຫລດເອົາ package ຂອງຄົນອື່ນມາໃຊ້ໃນ project ເຮົາໂດຍໃຊ້ go get ຄຳສັ່ງນີ້ຈະໄປສ້າງ Directory ຕ່າງໆຕາມຫລັງຂອງຄຳສັ່ງ go get ໃຫ້ເລີຍ ຖ້າວ່າ Directory ນັ້ນໆຍັງບໍ່ເຄີຍຖືກສ້າງ ຄືສົມມຸດວ່າເຮົາຕ້ອງການຈະໃຊ້ package ທີ່ເອົາໄວ້ເຊື່ອມກັບຖານຂໍ້ມູນ mysql ດ້ວຍຄຳສັ່ງດັ່ງນີ້</p><pre>$ go get -u github.com/go-sql-driver/mysql</pre><p>ມັນຈະໄປສ້າງໄວ້ທີ່:</p><p><strong>Directory</strong> github.com &gt; <strong>Directory</strong> go-sql-driver&gt;<strong>Directory</strong> mysql</p><p>ຈະໄດ້ Dorectory ລຸ່ມນີ້:</p><blockquote>C:/Users/Administrator/go/src/github.com/go-sql-driver/mysql</blockquote><p>ການສ້າງ Directory ຕາມ Pattern ທີ່ Github ໄດ້ແນະນຳໄວ້ກໍເພື່ອເວລາທີ່ເຮົາໄປ Download Package ຕ່າງໆຂອງ ພາສາ GO ສ່ວນຫລາຍແລ້ວກໍຈະຕັ້ງຕາມ Pattern ຂອງ Github.</p><p>ມາຕໍ່ກັນອີກໜ້ອຍໜຶ່ງ ໃຫ້ເຮົາຍ້າຍ folder hellogolang ຂອງເຮົາເຂົ້າໄປໄວ້ທີ່ Directory ທີ່ເຮົາສ້າງຂື້ນມາຕາມທີ່ Github ແນະນຳ ແລະ ເຮົາຈະໄດ້ Directory ດັ່ງນີ້:</p><blockquote>C:/Users/Administrator/go/src/github.com/phuangpheth/hellogolang</blockquote><p>ແລ້ວເຮົາມາລອງໃຊ້ go run main.go ໃຫ້ເບິ່ງອີກເທື່ອຫນຶ່ງ:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*ep0-y9r7e_IMA6aCzbls9g.png" /></figure><p>ເຊິ່ງຜົນທີ່ໄດ້ຮັບນັ້ນກໍອອກເຊັ່ນດຽວກັນເລີຍ.</p><h4>​​​​# ການ <strong>Build Source Code ຂອງພາສາ Go</strong></h4><p>ໃນການ Build Source Code ນັ້ນເຮົາຈະໃຊ້ຄຳສັ່ງ</p><blockquote>env GOOS=windows GOARCH=amd64 go build</blockquote><p>GOOS ແມ່ນ ເລືອກລະບົບປະຕິບັດການທີ່ Build</p><p>GOARCH ແມ່ນ ສະຖາປັດຕະຍາກຳຂອງ CPU ທີ່ຈະ Build</p><p>ເມື່ອເຮົາກົດ Enter ແລ້ວເຮົາກໍຈະໄດ້ file hellogolang.exe ຫຼື file ທີ່ຜ່ານການ Execute ເພື່ອໃຫ້ເຮົາສາມາດນຳໄປ Run ຢູ່ເຄື່ອງອື່ນໄດ້ເລີຍ.</p><p>ໃນການ run file ທີ່ຜ່ານການ Execute ແມ່ນຈະໃຊ້ຄຳສັ່ງ</p><blockquote>hellogolang.exe</blockquote><p>ເມື່ອເຮົາ Run file ນີ້ຜົນໄດ້ຮັບກໍຈະໄດ້ເຊັ່ນດຽວກັນກັບທີ່ຜ່ານມາ</p><p>ກໍຖືວ່າຈົບລົງໄປກັບການເລີ່ມຕົ້ນ Golang ແບບ ແມວໆ ຜິດພາດປະການໃດ ຫຼື ອະທິບາຍບໍ່ຖືກຈັງໃດກໍຝາກຄອມເມັ້ນຫຼືຕິຊົມໄດ້ເດີ້ ເພື່ອເປັນກຳລັງໃຈໃນການຂຽນບົດຕໍ່ໆໄປ</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b88ea93cd9af" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ເລີ່ມຕົ້ນຂຽນ PHP ເຊື່ອມຕໍ່ກັບຖານຂໍ້ມູນ MySQL]]></title>
            <link>https://p40pmn.medium.com/%E0%BB%80%E0%BA%A5%E0%BA%B5%E0%BB%88%E0%BA%A1%E0%BA%95%E0%BA%BB%E0%BB%89%E0%BA%99%E0%BA%82%E0%BA%BD%E0%BA%99-php-%E0%BB%80%E0%BA%8A%E0%BA%B7%E0%BB%88%E0%BA%AD%E0%BA%A1%E0%BA%95%E0%BB%8D%E0%BB%88%E0%BA%81%E0%BA%B1%E0%BA%9A%E0%BA%96%E0%BA%B2%E0%BA%99%E0%BA%82%E0%BB%8D%E0%BB%89%E0%BA%A1%E0%BA%B9%E0%BA%99-mysql-23abf4f6cb75?source=rss-27d932b42a6e------2</link>
            <guid isPermaLink="false">https://medium.com/p/23abf4f6cb75</guid>
            <category><![CDATA[php-mysql-database]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Pao Phouminith]]></dc:creator>
            <pubDate>Mon, 16 Sep 2019 13:01:01 GMT</pubDate>
            <atom:updated>2019-09-16T13:01:01.118Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*GC96zhqGLydyRzkY_EC_Eg.png" /></figure><p>ເຮົາຈະນຳໃຊ້ການຂຽນການເຊື່ອມຕໍ່ໃນຮູບແບບຂອງ <strong>mysqli</strong> ເຊິ່ງໂດຍຫລັກໆແລ້ວກໍຈະປະກອບດ້ວຍ<strong> function</strong> ທີ່ຕ້ອງໃຊ້ດັ່ງນີ້:</p><p>1. ການເຊື່ອມຕໍ່ <strong>Mysqli()</strong></p><p>2. ການ <strong>Query</strong> ແລະ ການດຶງເອົາຂໍ້ມູນອອກມາສະແດງຜົນດ້ວຍ <strong>fetch_assoc</strong></p><h4>#ການເຊື່ອມຕໍ່ກັບຖານຂໍ້ມູນ mysql</h4><p>ສິ່ງທີ່ເຮົາຕ້ອງມີກໍຄື : <strong>username</strong> ແລະ <strong>password</strong> ທີ່ໃຊ້ເຂົ້າເຖິງຖານຂໍ້ມູນຂອງເຮົາ, <strong>hostname</strong> , ແລະ ສຸດທ້າຍກໍຄືຊື່ຂອງ Database ຂອງເຮົານັ້ນເອງ</p><p>ມາເລີ່ມກັນເລີຍ:</p><blockquote>&lt;?php</blockquote><blockquote>$hostname = ‘localhost’;<br>$user= ‘root’;<br>$password=’1234’;<br>$dbname=’dbname’;</blockquote><blockquote>$connect = new mysqli($hostname,$user,$password,$dbname);<br>$connect-&gt;query(“SET NAMES UTF8”); // ເປັນການກຳນົດຄ່າໃຫ້ສາມາດອ່ານພາສາລາວໄດ້ເວລາເຮົາເພີ່ມຂໍ້ມູນພາສາລາວເຂົ້າຖານຂໍ້ມູນ</blockquote><blockquote>?&gt;</blockquote><p>ຈາກ <strong>code </strong>ດ້ານເທິງຈະເຫັນໄດ້ວ່າເຮົາໄດ້ມີການປະກາດຕົວປ່ຽນໄວ້ <strong>4</strong> ຕົວເພື່ອມາກັບຄ່າທີ່ເຮົາໄດ້ເວົ້າມາໃນພາກສ່ວນເທິ່ງຂອງບົດຄວາມ</p><blockquote>$connect = new mysqli($hostname, $user, $password , $dbname)</blockquote><p>ພາກສ່ວນນີ້ຈະເປັນການ ສ້າງຕົວປ່ຽນທີ່ຊື່ວ່າ $connect ຂື້ນມາໄວ້ເກັບຕົວເຊື່ອມຕໍ່ກັບຖານຂໍ້ມູນເພື່ອທີ່ຈະໄປນຳໃຊ້ໃນຫົວຂໍ້ຖັດໄປ</p><h4>#ການ Query ຂໍ້ມູນ</h4><p>ໃນການ <strong>query</strong> ແມ່ນຈຳມີການນຳໃຊ້<strong> function fetch_assoc</strong> ໃນການດຶງເອົາຂໍ້ມູນຈາກຖານຂໍ້ມູນນັ້ນມາສະແດງຜົນ</p><p>ເຊິ່ງເຮົາຈະດຶງເອົາຂໍ້ມູນມາຈາກຕາຕະລາງທີ່ຊື່ວ່າ: users ເຊິ່ງປະກອບດ້ວຍ <strong>column</strong> ດັ່ງນີ້ : <strong>user_id, username, email , address</strong></p><p>ກໍຈະໄດ້ດັ່ງນີ້:</p><blockquote>&lt;?php</blockquote><blockquote>$sql = “SELECT *FROM users”;</blockquote><blockquote>$result = $connect-&gt;query($sql);// ນຳເອົາຄຳສັ່ງ sql ເຂົ້າປະມວນຜົນ</blockquote><blockquote>for($data = $result-&gt;fetch_assoc()){</blockquote><blockquote>echo “User ID : ”.$data[“username”].” &lt;br&gt;”;</blockquote><blockquote>echo “Name : ”.$data[“username”].” &lt;br&gt;”;</blockquote><blockquote>echo “Email : “.$data[“email”].”&lt;br&gt;”;</blockquote><blockquote>echo “Address : ”.$data[“address”].” &lt;br&gt;”;</blockquote><blockquote>}</blockquote><blockquote>?&gt;</blockquote><p>ຈາກ code ດ້ານເທິງຈະເຫັນໄດ້ວ່າເຮົານຳໃຊ້ຕົວປ່ຽນ <strong>$connect </strong>ທີ່ເຮົາໄດ້ຈາກການເຊື່ອມຕໍ່ທີ່ເຮົາປະກາດໄວ້ທາງດ້ານເທິງນັ້ນເອງ.</p><p>ແລ້ວຕົວປ່ຽນ <strong>$sql</strong> ນີ້ແມ່ນຫຍັງຫຍັງລະ? ຕົວປ່ຽນ <strong>$sql</strong> ນີ້ເຮົາປະກາດຂື້ນມາເພື່ອທີ່ຈະໃຫ້ມັນມາເກັບຄ່າຄຳສັ່ງ <strong>sql</strong> ເພື່ອນຳເຂົ້າໄປປະມວນຜົນໃນ <strong>function query.</strong></p><p>ຕົວປ່ຽນ $result ແມ່ນເຮົາປະກາດຂື້ນມາເພື່ອເກັບເອົາຜົນໄດ້ຮັບຈາກການ <strong>query</strong> ເພື່ອທີ່ຈຳນຳໄປໃຊ້ຕໍ່ໃນພາກສ່ວນຂອງການດຶງຂໍ້ມູນມາສະແດງ.</p><p>ໃນການດຶງຂໍ້ມູນມາສະແດງນັ້ນແມ່ນເຮົາຈະໃຊ້<strong> for loop</strong> ເຂົ້າມາໃນການດຶງຂໍ້ມູນອອກມາເທື່ອລະແຖວ ໂດຍການປະກາດຕົວປ່ຽນ<strong> $data </strong>ມາເກັບຄ່າທີ່ໄດ້ໄວ້ແລ້ວນຳໄປສະແດງຜົນ</p><p>ແລ້ວຕົວຂອງ <strong>$data[“$username”]</strong> ນີ້ເດ ມັນແມ່ນຫຍັງ?</p><p>ມັນແມ່ນຕົວທີ່ເຮົາບອກໃຫ້ຕົວປ່ຽນ $data ນັ້ນວ່າຂໍ້ມູນບ່ອນທີ່ຈະເອົາສະແດງນັ້ນແມ່ນໄປເອົາມາຈາກ <strong>column</strong> ຕົວໃດໃນຕາຕະລາງໃນຖານຂໍ້ມູນຂອງເຮົາ ເພາະຕົວຂອງ<strong> $data </strong>ມັນເກັບຂໍ້ມູນ <strong>object</strong> ໄວ້ເຊິ່ງວ່າເວລາທີ່ຈະສະແດງຂອງມູນອອກມານັ້ນຕ້ອງໄດ້ລະບຸຕຳແຫນ່ງໃຫ້ມັນ.</p><p>ພຽງແຕ່ສາມຂັ້ນຕອນທ່ານກໍສາມາດດຶວເອົາຂໍ້ມູນຈາກຖານຂໍ້ມູນອອກມາສະແດງໄດ້ແລ້ວ…</p><p>ທວນຄືນສາມຂັ້ນຕອນຄື:</p><ol><li>ສ້າງ Object connection ຂອງເຮົາຂື້ນມາ</li><li>ເອີ້ນໃຊ້ function query() ເພື່ອປະມວນຜົນຄຳສັ່ງ sql</li></ol><p>3. ດຶງຂໍ້ມູນມາສະແດງດ້ວຍ function fetch_assoc().</p><p>ພຽງເທົ່ານີ້ທ່ານກໍສາມາດນຳໄປປະຍຸກໃຊ້ຕາມຄວາມຕ້ອງການໄດ້ເລີຍ.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23abf4f6cb75" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel Framework ການ Upload ຮູບລົງຖານຂໍ້ມູນ (Image Upload) (part 1)]]></title>
            <link>https://p40pmn.medium.com/laravel-framework-%E0%BA%81%E0%BA%B2%E0%BA%99-upload-%E0%BA%AE%E0%BA%B9%E0%BA%9A%E0%BA%A5%E0%BA%BB%E0%BA%87%E0%BA%96%E0%BA%B2%E0%BA%99%E0%BA%82%E0%BB%8D%E0%BB%89%E0%BA%A1%E0%BA%B9%E0%BA%99-image-upload-part-1-ca235527124a?source=rss-27d932b42a6e------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca235527124a</guid>
            <category><![CDATA[laravel-framework]]></category>
            <category><![CDATA[php-framework-laravel]]></category>
            <category><![CDATA[image-uploading]]></category>
            <dc:creator><![CDATA[Pao Phouminith]]></dc:creator>
            <pubDate>Wed, 27 Feb 2019 05:22:37 GMT</pubDate>
            <atom:updated>2019-09-06T04:21:14.404Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bryQ_FbLFbQF-GRAxLYtRA.png" /></figure><p>ເລີ່ມໂດຍການເຂົ້າໄປທີ່ Project ຂອງເຮົາແລ້ວສ້າງ Model ຂື້ນມາເພື່ອຈະໄປເກັບຂໍ້ມູນ, ເຊິ່ງ Model ກໍຄືການສ້າງຕາຕະລາງມາເກັບຂໍ້ມູນຫັ່ນເອງ</p><pre>php artisan make:model Image -m</pre><p>ໃນຄຳສັ່ງນີ້ແມ່ນເຮົາຈະສ້າງ Model ຕົວໜຶ່ງຂື້ນມາຊື່ວ່າ Image ພ້ອມທັງໃຫ້ມັນສ້າງ ຕົວ migration ຂື້ນມານຳເລີຍ. ແລ້ວເຮົາກໍຈະໄດ້ File model ໜຶ່ງຂຶື້ນມາ ໃຫ້ເຮົາເປີດ file ນັ້ນຂື້ນມາແລ້ວກຳນົດຊື່ Table, primary key ແລະ Timestamp ໃຫ້ກັບ Model ຂອງເຮົາດັ່ງຮູບຕົວຢ່າງລຸ່ມນີ້</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rt9NOsOMnNqG9x4yyQL2rQ.png" /></figure><p>ເມື່ອກຳນົດແລ້ວກໍກົດ Save ແລ້ວໄປເປີດ File migration ທິ່ສ້າງຂື້ນມາພ້ອມກັບ Model Image ເຮົາ. File migration ຈະເປັນບ່ອນໃຫ້ເຮົາກຳນົດວ່າໃນຕາຕະລາງເຮົານັ້ນຈະໃຫ້ມີຈັກ Column, ມາກຳນົດກັນເລີຍ ໃນບົດຄວາມນີ້ທາງຜູ້ຂຽນຈະກຳນົດດັ່ງຮູບນີ້</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YuvX8UvwAULwdLurpd8WzA.png" /></figure><blockquote>ຈະມີ column ທີ່ໄວ້ເກັບ path ຂອງຮູບທີ່ຊື່ວ່າ image_path ແລະ column ທີ່ໄວ້ເກັບຄຳອະທິບາຍຂອງຮູບທີ່ title ກໍຈະມີເທົ່ານີ້ ນອກນັ້ນມັນຕົວ Laravel ຈັດການມາໃຫ້ເຮົາເລີຍ.</blockquote><p>ເມື່ອກຳນົດແລ້ວກໍ Save ແລ້ວໃຊ້ຄຳສັ່ງ migrate ເພື່ອຈະສ້າງ Table images ຂື້ນມານັ້ນເອງ.</p><p>ແຕ່ກ່ອນຈະໃຊ້ຄຳສັ່ງ migrate ໃຫ້ໄປແກ້ໄຂ App/Providers/AppServiceProvider.php ໂດຍການເພີ່ມ code ລຸ່ມນີ້ເຂົາໄປ</p><pre>use Illuminate\Support\Facades\Schema;</pre><blockquote>ແລະ ເພີ່ມຄ່າ <strong>Default</strong> ໃຫ້ກັບຕົວເກັບຂໍ້ມູນປະເພດ <strong>string</strong> ຫັ່ນ (ການເກັບແບບ <strong>string</strong> ນີ້ກໍແມ່ນອັນດຽວກັນກັບເຮົາເກັບຂໍ້ມູນແບບ <strong>varchar</strong> ເຊິ່ງຈະຕ້ອງໄດ້ກຳນົດຂະໜາດຂອງການເກັບໃຫ້ມັນ)</blockquote><p>ໂດຍໃຫ້ເພີ່ມ code ລຸ່ມນີ້ເຂົ້າໄປໃນ public function boot()</p><pre>Schema::defaultStringLength(191);</pre><p>ຮູບຕົວຢ່າງ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XDChSR7-x_ZGIUoP1nmsHg.png" /></figure><p>ເມື່ອກຳນົດແລ້ວກຳມາໃຊ້ຄຳສັ່ງ</p><pre>php artisan migrate</pre><p>ກໍຈະໄດ້ Table image ຂື້ນມາແລ້ວນະຕອນນີ້ ຕໍ່ມາເຮົາຈະສ້າງ Controller ຂື້ນມາເພື່ອທີ່ຈະມາຈັດການກັບການເພີ່ມ, ການລຶບ, ການແກ້ໄຂ ແລະ ການສະແດງຂໍ້ມູນ ເຮົາຈະສ້າງ Controller ຊື່ວ່າ ImagesController ຂື້ນມາດ້ວຍຄຳສັ່ງ</p><pre>php artisan make:controller ImagesControll --resource</pre><p>ເຊິ່ງມັນຈະສ້າງ Function ທີ່ຈັດການກັບຂໍ້ມູນຕາມທີ່ເວົ້າມາຂ້າງເທິງ.</p><p>ຕໍ່ມາກໍເປີດ file controller ທີ່ເຮົາສ້າງຂື້ນມາຫັ່ນ ແລ້ວ import ເອົາ Model ທີ່ເຮົາສ້າງໄວ້ຫັ່ນເຂົ້າມາໃຊ້ໃນ controller ຕົວດັ່ງກ່າວນີ້</p><blockquote>use App\Image; // import model image ເຂົ້າມາໃຊ້ໃນ ImagesController</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*1St9dzG4utx19cvtDZq6fw.png" /></figure><h4>ແລ້ວໄປກຳນົດ Route ໃຫ້ກັບຕົວ Resource ໃນ Route/web.php</h4><blockquote>Resource(‘/images’,’ImagesController’);</blockquote><p>ຈາກນັ້ນໃຫ້ໄປສ້າງ File template ຕາມແບບຂອງ Laravel ຂື້ນມາ ໃນບົດຄວາມນີ້ຈະສ້າງຂື້ນມາ 2 file ຄື index.blade.php ແລະ create.blade.php</p><h4>ສ່ວນ Code ຂອງ File index.blade.php</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*26FXh9qgr3KfZhwYoidBpA.png" /></figure><p>ກໍຈະເປັນໜ້າທີ່ໄວ້ສະແດງຂໍ້ມູນຮູບທັງຫມົດທີ່ເຮົາໄດ້ Upload ໄປນັ້ນເອງ</p><p>ຮູບຕົວຢ່າງຂອງໜ້າ index.blade.php</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jp1rny3GH-1BpTrKvcNovA.png" /></figure><h4>ສ່ວນ Code ຂອງ File create.blade.php</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jzAQi4WfjFId12ZTv4da0A.png" /></figure><p>ຈະເປັນ Form ທີ່ຮັບຂໍ້ມູນ ຮູບຕົວຢ່າງຂອງໜ້າ create.blade.php</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rotIdpEwk0lK2t9D_RzNJQ.png" /></figure><h4>ສ່ວນ Code ຂອງ File ImagesController ໃນ public function index()</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p9skg4gh8_oX7wv3aGj7Sw.png" /></figure><p>ກໍຄືຈະເປັນການໄປດຶງຂໍ້ມູນອອກມາຈາກຖານຂໍ້ມູນແລ້ວສົ່ງຄ່າໄປສະແດງຢູ່ index.blade.php ນັ້ນເອງ.</p><h4>ສ່ວນ Code ຂອງ File ImagesController ໃນ public function create()</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*KiwHPM3_CmwsuWXc3u1b0Q.png" /></figure><p>ຈະເປັນການເອີ້ນເອົາ file create.blade.php ນັ້ນມາສະແດງເມື່ອເຮົາກົດປຸ່ມ <strong>Upload New Image </strong>ໃນໜ້າ index.blade.php</p><h4>ສ່ວນ Code ຂອງ File ImagesController ໃນ public function store(Request $request)</h4><p>ຈະເປັນ Function ທີ່ບັນທຶກຂໍ້ມູນລົງຖານຂໍ້ມູນນັ້ນເອງ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rn6I_Iogo7igbyYdNUTDTA.png" /></figure><p>ກໍຖືວ່າຈົບລົງໄປກັບການ Upload Image to Database ໂດຍໃຊ້ Laravel Framework.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca235527124a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel Framework ການນຳໃຊ້ CKEditor Package ເຂົ້າໃນການຮັບຂໍ້ມູນ]]></title>
            <link>https://p40pmn.medium.com/laravel-framework-%E0%BA%81%E0%BA%B2%E0%BA%99%E0%BA%99%E0%BA%B3%E0%BB%83%E0%BA%8A%E0%BB%89-ckeditor-package-%E0%BB%80%E0%BA%82%E0%BA%BB%E0%BB%89%E0%BA%B2%E0%BB%83%E0%BA%99%E0%BA%81%E0%BA%B2%E0%BA%99%E0%BA%AE%E0%BA%B1%E0%BA%9A%E0%BA%82%E0%BB%8D%E0%BB%89%E0%BA%A1%E0%BA%B9%E0%BA%99-47f74d91270e?source=rss-27d932b42a6e------2</link>
            <guid isPermaLink="false">https://medium.com/p/47f74d91270e</guid>
            <category><![CDATA[php-frame-work]]></category>
            <category><![CDATA[ckeditor]]></category>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[Pao Phouminith]]></dc:creator>
            <pubDate>Sun, 24 Feb 2019 03:02:35 GMT</pubDate>
            <atom:updated>2019-02-24T03:02:35.643Z</atom:updated>
            <content:encoded><![CDATA[<p>ຈະໃຊ້ຄຳສັ່ງຂອງ Composer ໃນການ Set up package. ໃຫ້ເປີດ Terminal ຂື້ນມາໃນ Folder Project ຂອງເຮົາແລ້ວກໍໃຊ້ຄຳສັ່ງລຸ່ມນີ້:</p><pre>composer require unisharp/laravel-ckeditor</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*gyZ5ITOIoBq8cPaZ9VWLGg.png" /></figure><p>ຈາກນັ້ນກໍໃຫ້ໄປແກ້ໄຂ config/app.php ເພື່ອເພີ່ມ Service Providers</p><pre>Unisharp\Ckeditor\ServiceProvider::class,</pre><p>ໄປເພີ່ມ Service Providers ນີ້ເຂົ້າໃນ Array ຂອງ providers ແລ້ວກໍ <strong>Save.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*MWXBlznN50oA1fZuR5oAkQ.png" /></figure><p>ແລ້ວກໍເປີດ Terminal ຂື້ນມາອີກ ໃຫ້ໃຊ້ຄຳສັ່ງລຸ່ມນີ້ເພື່ອຈະເຮັດໃຫ້ເຮົານຳໃຊ້ຊັບພະຍາກອນຂອງ ckeditorໄດ້.</p><pre>php artisan vendor:publish --tag=ckeditor</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*MpeH_4C4d91XiUBkFbUBvQ.png" /></figure><p>ກໍຈະສຳເລັດສຳລັບການ Set up package ຂອງ CKEditor Package.</p><p>ການນຳໃຊ້ແມ່ນໃຫ້ເຮົານຳເອົາສ່ວນຂອງ code ທາງດ້ານລຸ່ມນີ້ໄປເພີ່ມເຂົ້າໃນ File ຂອງໂຄງສ້າງ web ເຮົາເຊັ່ນ layouts/app.blade.php</p><pre>&lt;script src=&quot;/vendor/unisharp/laravel-ckeditor/ckeditor.js&quot;&gt;  &lt;/script&gt;<br> &lt;script&gt;<br>        CKEDITOR.replace( &#39;article-ckeditor&#39; );<br> &lt;/script&gt;</pre><p>ດັ່ງຮູບຕົວຢ່າງ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fW0DL2HqeOlxUX-vSoTpmA.png" /></figure><blockquote>ໂດຍຄ່າ Default ໃນການເອີ້ນໃຊ້ຈະເປັນຮູບແບບ Name ຫຼື ID ກໍໄດ້ ແຕ່ໃນຕົວຢ່າງລຸ່ມນີ້ເຮົາຈະເອີ້ນໃຊ້ຜ່ານ ID ເຮົາກໍໄປກຳນົດ ID ໃຫ້ກັບ Text Input ທີ່ເຮົາຢາກຈະໃຊ້ CKEditor ນີ້ເຂົ້າໄປ ໂດຍໃຊ້ຊື່ ID ວ່າ : <strong>article-ckeditor</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bTWYO0GP6VMjwl5fV6Nmyw.png" /></figure><p>ຂໍ້ມູນອ້າງອີງ:<a href="https://github.com/UniSharp/laravel-ckeditor#publish-the-resources">https://github.com/UniSharp/laravel-ckeditor#publish-the-resources</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=47f74d91270e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel Framework ການໃຊ້ Laravel Collective Forms & HTML ເຂົ້າໃນ Project ແລະ ການນຳໃຊ້ເບື່ອງຕົ້ນ…]]></title>
            <link>https://p40pmn.medium.com/laravel-framework-%E0%BA%81%E0%BA%B2%E0%BA%99%E0%BB%83%E0%BA%8A%E0%BB%89-laravel-collective-forms-html-%E0%BB%80%E0%BA%82%E0%BA%BB%E0%BB%89%E0%BA%B2%E0%BB%83%E0%BA%99-project-%E0%BB%81%E0%BA%A5%E0%BA%B0-%E0%BA%81%E0%BA%B2%E0%BA%99%E0%BA%99%E0%BA%B3%E0%BB%83%E0%BA%8A%E0%BB%89%E0%BB%80%E0%BA%9A%E0%BA%B7%E0%BB%88%E0%BA%AD%E0%BA%87%E0%BA%95%E0%BA%BB%E0%BB%89%E0%BA%99-3e1187496fab?source=rss-27d932b42a6e------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e1187496fab</guid>
            <category><![CDATA[html-form]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[laravel-framework]]></category>
            <dc:creator><![CDATA[Pao Phouminith]]></dc:creator>
            <pubDate>Sat, 23 Feb 2019 00:20:22 GMT</pubDate>
            <atom:updated>2019-02-23T00:45:52.903Z</atom:updated>
            <content:encoded><![CDATA[<h3>Laravel Framework ການໃຊ້ Laravel Collective Forms &amp; HTML ເຂົ້າໃນ Project ແລະ ການນຳໃຊ້ເບື່ອງຕົ້ນ</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2xY8na4xRQtt6lGLGlD3vw.png" /></figure><p>Open terminal ຂື້ນມາໃນ Folder Project ຂອງເຮົາ ແລ້ວໃຊ້ຄຳສັ່ງ composerລຸ່ມນີ້ເພື່ອຈະຕິດຕັ້ງ Laravel Collective Forms</p><pre>composer require &quot;laravelcollective/html&quot;:&quot;^5.4.0&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*vP9wLy3lbfraDjDisXoMMw.png" /></figure><p>ຈາກນັ້ນໃຫ້ເຂົ້າໄປແກ້ໄຂ File ທີ່ຢູ່ໃນ <strong>config/app.php</strong> ເພື່ອຈະເພີ່ມ Service Providers ໃໝ່ເຂົ້າໄປໃນ <strong>Array</strong> ຂອງ <strong>providers </strong>ເຊິ່ງ Service ທີ່ຈະເພີ່ມເຂົ້າໄປແມ່ນ:</p><pre>Collective\Html\HtmlServiceProvider::class</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*pISrlb6OxUrPNb-mMqn-ww.png" /></figure><p>ຕໍ່ໄປກໍໃຫ້ໄປເພີ່ມ Service ເຂົ້າໃນ Array ຂອງ <strong>aliases</strong> ໃນ File<strong> </strong>ດຽວກັນ</p><pre>// ...<br>      &#39;Form&#39; =&gt; Collective\Html\FormFacade::class,<br>      &#39;Html&#39; =&gt; Collective\Html\HtmlFacade::class,<br>// ...</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/503/1*Yj27RQtirXm82L2KrB5_WA.png" /></figure><p>ແລ້ວກໍກົດ <strong>save</strong> ກໍຈະຖືວ່ານຳໃຊ້ໄດ້ເລີຍ.</p><h4>ມາລອງນຳໃຊ້ກັນເບິ່ງເລີຍ</h4><pre>{!! Form::open([&#39;url&#39; =&gt; &#39;foo/bar&#39;]) !!}<br>    //<br>{!! Form::close() !!}</pre><p>ໃຊ້ <strong>Form::open</strong> ແລະ <strong>Form::close</strong> ນີ້ເພື່ອຈະເລີ່ມສ້າງ Form ຮັບຂໍ້ມຸນ.</p><p><strong>Form::open</strong> ແມ່ນມັນຈະປະກອບໄປດ້ວຍ Attribute ຢູ່ 2 ຕົວຫຼັກໆຄື:</p><ol><li><strong>action</strong> : ຈະເປັນຕົວກຳນົດ URL ທີ່ເຮົາຈະນຳຂໍ້ມູນໄປເກັບນັ້ນເອງ</li></ol><p>2.<strong> method</strong> :ຖ້າຈະແປຕາມໂຕກໍຄືວິທີທີ່ເຮົາຈະສົ່ງຂໍ້ມູນໄປນັ້ນເອງ ໂດຍຫຼັກໆແລ້ວກໍຈະປະກອບມີ POST, GET, PUT ແລະ DELETE ແຕ່ວ່າໃນ HTML forms ຈະ support ພຽງແຕ່POST ແລະ GET ເທົ່ານັ້ນ. ສ່ວນ PUT ແລະ DELETE ຈະໃຊ້ໂດຍການເພີ່ມ <strong>Form::hidden </strong>ນີ້ເຂົ້າມາ ຈະເປັນຮູບແບບການສົ່ງຄ່າຂໍ້ມູນທີ່ມີ <strong>parameter</strong> ໄປນຳ</p><pre>{{Form::hidden(‘_method’, ‘PUT’)}}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BGDlTcz3a9AtlFmBDZWNmA.png" /></figure><p>ກໍຈະຖືວ່າສຳເລັດກັບການນຳໃຊ້ Laravel Collective Forms &amp; HTML ເຊິ່ງສາມາດໄປສຶກສາໄດ້ຕື່ມຕາມຂໍ້ມູນອ້າງອີງ: <a href="https://laravelcollective.com/docs/5.4/html">https://laravelcollective.com/docs/5.4/html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e1187496fab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel Framework ການຕິດຕັ້ງ ແລະ ນຳໃຊ້ເບື່ອງຕົ້ນ (Part 1)]]></title>
            <link>https://p40pmn.medium.com/laravel-framework-%E0%BA%81%E0%BA%B2%E0%BA%99%E0%BA%95%E0%BA%B4%E0%BA%94%E0%BA%95%E0%BA%B1%E0%BB%89%E0%BA%87-%E0%BB%81%E0%BA%A5%E0%BA%B0-%E0%BA%99%E0%BA%B3%E0%BB%83%E0%BA%8A%E0%BB%89%E0%BB%80%E0%BA%9A%E0%BA%B7%E0%BB%88%E0%BA%AD%E0%BA%87%E0%BA%95%E0%BA%BB%E0%BB%89%E0%BA%99-part-1-e702dc25670e?source=rss-27d932b42a6e------2</link>
            <guid isPermaLink="false">https://medium.com/p/e702dc25670e</guid>
            <category><![CDATA[php-frameworks]]></category>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[Pao Phouminith]]></dc:creator>
            <pubDate>Fri, 22 Feb 2019 14:03:27 GMT</pubDate>
            <atom:updated>2019-02-23T00:45:24.374Z</atom:updated>
            <content:encoded><![CDATA[<h3>Laravel Framework ການຕິດຕັ້ງ ແລະ ນຳໃຊ້ເບື່ອງຕົ້ນ</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*t7vqj3on_xgTicPcYWTisw.jpeg" /><figcaption><a href="https://laravel.com/">https://laravel.com</a></figcaption></figure><p><a href="https://laravel.com/"><strong>Laravel</strong></a><strong> </strong>ເປັນ framework ອັນຫນຶ່ງຂອງ PHP ທີ່ໄດ້ຮັບຄວາມນິຍົມກັນຫລາຍໃນກຸ່ມຂອງນັກພັດທະນາ <strong>Back-End Developer </strong>ເຊົິ່ງມາພ້ອມກັບຮູບແບບຂອງ MVC <strong>(Model Views Controller) </strong>ທີ່ເຮັດໃຫ້ການຂຽນ <strong>Code</strong> ໄວ, ງ່າຍຕໍ່ການອ່ານ ແລະ ແກ້ໄຂ, ທີ່ສຳຄັນແມ່ນສາມາດໂຫລດມາໃຊ້ງານໄດ້ແບບຟຣີໆອີກ ອາໂກຍ!!! ມັນກະຄັກໂລດແລ້ວສິຖ້າຫຍັງລະໄປລົງມືໃຊ້ງານມັນກັນເລີຍ. ^^</p><h3><strong>ການຕິດຕັ້ງ Laravel ເບື່ອງຕົ້ນ.</strong></h3><p>ກ່ອນທີ່ຈະຕິດຕັ້ງ Laravel ແມ່ນຈຳເປັນຕ້ອງໄດ້ໄປລົງຕົວ <a href="https://getcomposer.org/download/"><strong>composer</strong></a><strong> </strong>ກ່ອນ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*RuImYMz3z1uJp0MQ_I0cGA.png" /><figcaption><a href="https://getcomposer.org/download/">https://getcomposer.org/download/</a></figcaption></figure><p>ເຊົິ່ງຕົວ <a href="https://getcomposer.org/download/"><strong>composer</strong></a> ຖືໄດ້ວ່າເປັນພະເອກເລີຍກໍວ່າໄດ້ເພາະເຮົາຈະໃຊ້ມັນໃນການໃນການຕິດຕັ້ງ <strong>Laravel Framework </strong>.</p><p>ເມື່ອລົງຕົວ <strong>Composer</strong> ແລ້ວເຮົາມາເລີ່ມກັນເລີຍໂດຍການເປີດ <strong>Folder</strong> ບ່ອນທີ່ເຮົາລົງ <strong>Server</strong> ຈຳລອງໄວ້ ໃນທີ່ນີ້ເຮົາໄດ້ໃຊ້ <strong>Xampp</strong> ໃນການເປັນ Server ຈຳລອງ ເຊິ່ງ <strong>Folder </strong>ໃນທີ່ແມ່ນ <strong>htdocs </strong>ເມື່ອເຂົ້າໄປໃນ <strong>Folder</strong> ນີ້ແລ້ວກໍໃຊ້ຄຳສັ່ງຂອງ <strong>Composer</strong> ເພື່ອລົງ <strong>Laravel </strong>ກັນເລີຍ.</p><blockquote><em>composer create-project --prefer-dist laravel/laravel</em> Project_Name</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*9kJWj1NTXpjLS97dixhVcQ.png" /></figure><p>ເມື່ອເຮົາໂຫລດມາແລ້ວໃຫ້ເຂົ້າໄປໃນ <strong>Folder </strong>ໂປຣເຈັກຂອງເຮົາ (<em>ໃນຕົວຢ່າງນີ້ທາງຜູ້ຂຽນໄດ້ໃສ່ຊື່ເປັນ </em><strong>webapp</strong>) ຈາກນັ້ນກໍໃຊ້ຄຳສັ່ງລຸມນີ້ເພື່ອສັ່ງທົດສອບ <strong>Run </strong>ໂປຣເຈັກທີ່ເຮົາຫາກໍລົງໄປ.</p><blockquote><em>php artisan serv</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*rpsgO1r6LrQ2ajuzcx5hzg.png" /></figure><p>ເມື່ອກົດ Enter ມັນກໍຈະໃຫ້ URL <a href="http://127.0.0.1:8000/">http://127.0.0.1:8000/</a> ມາໃຫ້ເຮົາ ດັ່ງໃນຮູບ, ແລ້ວກໍພຽງແຕ່ເອົາ URL ນັ້ນໄປຂຽນໃສ່ Tap URL ໃນ <strong>Web browser</strong> ຂອງເຮົາເລີຍຖ້າບໍ່ມີຫຍັງຜິດພາດກໍຈະຖືວ່າສຳເລັດ.</p><p>ກໍຈະຖືວ່າໝົດເທົ່ານີ້ສຳລັບການຕິດຕັ້ງ <a href="https://laravel.com/"><strong>Laravel</strong></a><strong> </strong>ເບື່ອງຕົ້ນ.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e702dc25670e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>