Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tools:ci4 [2022/05/16 15:59] – [Hello world] darrontools:ci4 [2022/08/19 12:24] (current) – [Resources] darron
Line 8: Line 8:
  
 ===Install Apache & PHP=== ===Install Apache & PHP===
 +
 +Update 
  
 <code> <code>
 apt update apt update
 apt full-upgrade apt full-upgrade
-apt install apache2 php php-cli php-mbstring php-intl php-curl+</code> 
 + 
 +Install 
 + 
 +<code> 
 +apt install apache2 php php-cli php-mbstring php-intl php-curl php-json php-mysqlnd php-xml 
 +</code> 
 + 
 +PHP version 
 + 
 +<code> 
 +php --version 
 +PHP 7.4.28 (cli) (built: Feb 17 2022 16:17:19) ( NTS ) 
 +Copyright (c) The PHP Group 
 +Zend Engine v3.4.0, Copyright (c) Zend Technologies 
 +    with Zend OPcache v7.4.28, Copyright (c), by Zend Technologies 
 +</code> 
 + 
 +===Install MySQL=== 
 + 
 +Install MariaDB fork of MySQL. 
 + 
 +<code> 
 +apt-get install default-mysql-server default-mysql-client 
 +</code> 
 + 
 +MySQL version 
 + 
 +<code> 
 +mysql --version 
 +mysql  Ver 15.1 Distrib 10.5.15-MariaDB, for debian-linux-gnu (x86_64) using  EditLine wrapper
 </code> </code>
  
Line 22: Line 54:
 mkdir -p /var/www/htdocs mkdir -p /var/www/htdocs
 cd /var/www/htdocs cd /var/www/htdocs
-wget https://api.github.com/repos/codeigniter4/CodeIgniter4/zipball/v4.1.-O ci4.zip +wget https://api.github.com/repos/codeigniter4/CodeIgniter4/zipball/v4.2.-O ci4.2.4.zip 
-unzip ci4.zip +unzip ci4.2.4.zip 
-mv codeigniter4-CodeIgniter4-202f41a hostname.kewl.org+mv codeigniter4-CodeIgniter4-hostname.kewl.org
 cd hostname.kewl.org cd hostname.kewl.org
 chown www-data:www-data writable chown www-data:www-data writable
 </code> </code>
  
 +Warning: 4.1 would auto-detect routes but this is not the case with 4.2.
 ===Configure apache=== ===Configure apache===
  
Line 42: Line 75:
     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d     RewriteCond %{REQUEST_FILENAME} !-d
-    RewriteRule .* /index.php/$1 [L]+    RewriteRule .* /var/www/htdocs/hostname.kewl.org/public/index.php [L]
  
     <Directory "/var/www/htdocs/hostname.kewl.org/public">     <Directory "/var/www/htdocs/hostname.kewl.org/public">
Line 70: Line 103:
 === Hello world==== === Hello world====
  
-Create controller.+==Controller==
  
 <code> <code>
Line 91: Line 124:
 </code> </code>
  
-Create view+==Index view==
  
 <code> <code>
-vi app/Views/Hello.php+vi app/Views/Index.php
 </code> </code>
  
Line 101: Line 134:
 <html lang="en"> <html lang="en">
 <head> <head>
-    <title>Hello World</title>+    <title>Index</title>
 </head> </head>
 <body> <body>
  
-<p>Hello World</p>+<!--Content start--> 
 +<?=$this->renderSection("Content")?> 
 +<!--Content end-->
  
 </body> </body>
Line 111: Line 146:
 </code> </code>
  
-Visit URL+==Controller view== 
 + 
 +<code> 
 +vi app/Views/Hello.php 
 +</code> 
 + 
 +<code> 
 +<?php 
 +    $this->extend("Index"); 
 +    $this->section("Content"); 
 +    phpinfo(); 
 +    $this->endSection(); 
 +?> 
 +</code> 
 + 
 +==Route== 
 + 
 +vi app/Config/Routes.php 
 +<code> 
 +$routes->get('/Hello', 'Hello::index'); 
 +</code> 
 + 
 +==URL==
  
 <code> <code>
Line 117: Line 174:
 </code> </code>
  
 +===Resources===
 +
 +[[https://codeigniter4.github.io/CodeIgniter4/outgoing/view_layouts.html|View layouts]]
 +
 +[[https://codeigniter.com/user_guide/incoming/routing.html|Routing]]
 +
 +[[https://onlinewebtutorblog.com/codeigniter-4/what-is-codeigniter/|Basic overview]]