diff --git a/.htaccess b/.htaccess deleted file mode 100644 index 0d0f372..0000000 --- a/.htaccess +++ /dev/null @@ -1,4 +0,0 @@ -# This file is - if you set up MINI correctly - not needed. -# But, for fallback reasons (if you don't route your vhost to /public), it will stay here. -RewriteEngine on -RewriteRule ^(.*) public/$1 [L] diff --git a/README.md b/README.md index 5656cc4..2899152 100644 --- a/README.md +++ b/README.md @@ -3,11 +3,12 @@ # MINI3 MINI3 is an extremely simple and easy to understand skeleton PHP application, reduced to the max. -MINI3 is NOT a professional framework and it does not come with all the stuff real frameworks have. +MINI3 is NOT a professional framework and does not come with all the stuff real frameworks have. If you just want to show some pages, do a few database calls and a little-bit of AJAX here and there, without reading in massive documentations of highly complex professional frameworks, then MINI3 might be very useful for you. MINI3 is easy to install, runs nearly everywhere and doesn't make things more complicated than necessary. + [MINI](https://github.com/panique/mini) (original version) and [MINI2](https://github.com/panique/mini2) (used Slim router) were built by me (panique), MINI3 is an excellent and improved version of the original MINI, made by [JaoNoctus](https://github.com/JaoNoctus). Big thanks, man! :) @@ -24,12 +25,37 @@ of the original MINI, made by [JaoNoctus](https://github.com/JaoNoctus). Big tha - uses only native PHP code, so people don't have to learn a framework - uses PSR-4 autoloader -## Requirements +## Requirements (but it's auto-installed) -- PHP 5.6 or PHP 7.0 +- PHP 8 - MySQL -- mod_rewrite activated (see below for tutorials) - basic knowledge of Composer for sure +- for auto-installation: VirtualBox, Vagrant + +## Forks + +There are some nice upgraded versions of this mini framework, check it out at https://github.com/ribafs/php-router + +## Installation (in Vagrant, 100% automatic) + +To keep things super-simple, we are using Vagrant here, a simple technology to run virtual machines for development. +It's outdated, but does the job, and is much easier to understand than Docker. Just install VirtualBox, Vagrant, then +copy this repo's code to a folder, go to that folder and type: + +```bash +vagrant up +``` + +This will create a virtual machine with the configs given in `Vagrantfile`: It will create an Ubuntu 2022.04 Jammy64 +VM with 1024MB RAM, sync the current folder to `/var/www/html` inside the VM, make the VM available on the IP +`192.168.56.77` and start the bash script `bootstrap.sh`, which is just a set of commands that will install all +necessary software. + +If the auto-installer is finished, go to http://192.168.56.77 in your browser and click around a bit ;) + +# OLD INSTALLATION TUTORIALS FROM 2016 + +Below you'll find installation tutorial for the old version of MINI3 from 2016. ## Installation (in Vagrant, 100% automatic) @@ -336,4 +362,4 @@ And by the way, I'm also blogging at [Dev Metal](http://www.dev-metal.com) :) ## Support the project -Rent your next server at [1&1](http://www.kqzyfj.com/click-8225476-12015878-1477926464000) to support this open source project. +Buy Me A Coffee diff --git a/_vagrant/Vagrantfile b/Vagrantfile old mode 100644 new mode 100755 similarity index 79% rename from _vagrant/Vagrantfile rename to Vagrantfile index 0737289..a0b96fb --- a/_vagrant/Vagrantfile +++ b/Vagrantfile @@ -6,11 +6,15 @@ VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| - # Every Vagrant virtual environment requires a box to build off of. - config.vm.box = "ubuntu/trusty64" + # Ubuntu 2022.04 + config.vm.box = "ubuntu/jammy64" # Create a private network, which allows host-only access to the machine using a specific IP. - config.vm.network "private_network", ip: "192.168.33.66" + config.vm.network "private_network", ip: "192.168.56.77" + + config.vm.provider "virtualbox" do |vb| + vb.memory = "1024" + end # Share an additional folder to the guest VM. The first argument is the path on the host to the actual folder. # The second argument is the path on the guest to mount the folder. diff --git a/_install/01-create-database.sql b/_install/mysql/01-create-database.sql similarity index 100% rename from _install/01-create-database.sql rename to _install/mysql/01-create-database.sql diff --git a/_install/02-create-table-song.sql b/_install/mysql/02-create-table-song.sql similarity index 100% rename from _install/02-create-table-song.sql rename to _install/mysql/02-create-table-song.sql diff --git a/_install/03-insert-demo-data-into-table-song.sql b/_install/mysql/03-insert-demo-data-into-table-song.sql similarity index 100% rename from _install/03-insert-demo-data-into-table-song.sql rename to _install/mysql/03-insert-demo-data-into-table-song.sql diff --git a/_install/nginx/default b/_install/nginx/default new file mode 100644 index 0000000..69389e7 --- /dev/null +++ b/_install/nginx/default @@ -0,0 +1,24 @@ +server { + listen 80 default_server; + listen [::]:80 default_server; + + root /var/www/html/public; + + index index.html index.htm index.nginx-debian.html; + + server_name _; + + location / { + index index.php; + try_files /$uri /$uri/ /index.php?url=$uri; + } + + location ~ \.php$ { + include snippets/fastcgi-php.conf; + fastcgi_pass unix:/run/php/php8.1-fpm.sock; + } + + location ~ /\.ht { + deny all; + } +} \ No newline at end of file diff --git a/_vagrant/bootstrap.sh b/_vagrant/bootstrap.sh deleted file mode 100644 index c50878e..0000000 --- a/_vagrant/bootstrap.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env bash - -# If you want to use a custom password for your database, then change it here, this script will install MySQL / -# phpmyadmin with that password and also put this into MINI3's config file. -# Use single quotes instead of double quotes to make it work with special-character passwords -PASSWORD='12345678' -PROJECTFOLDER='myproject' - -sudo apt-get update -sudo apt-get -y upgrade - -sudo apt-get install -y apache2 -sudo apt-get install -y php5 - -sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password $PASSWORD" -sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $PASSWORD" -sudo apt-get -y install mysql-server -sudo apt-get install php5-mysql - -sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/dbconfig-install boolean true" -sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/app-password-confirm password $PASSWORD" -sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/mysql/admin-pass password $PASSWORD" -sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/mysql/app-pass password $PASSWORD" -sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2" -sudo apt-get -y install phpmyadmin - -# Create project folder, written in 3 single mkdir-statements to make sure this runs everywhere without problems -sudo mkdir "/var/www" -sudo mkdir "/var/www/html" -sudo mkdir "/var/www/html/${PROJECTFOLDER}" - -# setup hosts file -VHOST=$(cat < - DocumentRoot "/var/www/html/${PROJECTFOLDER}/public" - - AllowOverride All - Require all granted - - -EOF -) -echo "${VHOST}" > /etc/apache2/sites-available/000-default.conf - -# enable mod_rewrite -sudo a2enmod rewrite - -# restart apache -service apache2 restart - -# remove default apache index.html -sudo rm "/var/www/html/index.html" - -# install git -sudo apt-get -y install git - -# git clone MINI -sudo git clone https://github.com/panique/mini3 "/var/www/html/${PROJECTFOLDER}" - -# install Composer -curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer - -# go to project folder, create the PSR4 autoloader with Composer -cd "/var/www/html/${PROJECTFOLDER}" -composer install - -# run SQL statements from MINI3 folder -sudo mysql -h "localhost" -u "root" "-p${PASSWORD}" < "/var/www/html/${PROJECTFOLDER}/_install/01-create-database.sql" -sudo mysql -h "localhost" -u "root" "-p${PASSWORD}" < "/var/www/html/${PROJECTFOLDER}/_install/02-create-table-song.sql" -sudo mysql -h "localhost" -u "root" "-p${PASSWORD}" < "/var/www/html/${PROJECTFOLDER}/_install/03-insert-demo-data-into-table-song.sql" - -# put the password into the application's config. This is quite hardcore, but why not :) -sudo sed -i "s/12345678/${PASSWORD}/" "/var/www/html/${PROJECTFOLDER}/application/config/config.php" - -# final feedback -echo "Voila!" diff --git a/application/Core/Application.php b/application/Core/Application.php index f6976ed..e6cb686 100644 --- a/application/Core/Application.php +++ b/application/Core/Application.php @@ -37,7 +37,7 @@ public function __construct() $this->url_controller = new $controller(); // check for method: does such a method exist in the controller ? - if (method_exists($this->url_controller, $this->url_action)) { + if (method_exists($this->url_controller, (string) $this->url_action)) { if (!empty($this->url_params)) { // Call the method and pass arguments to it @@ -48,7 +48,7 @@ public function __construct() } } else { - if (strlen($this->url_action) == 0) { + if (empty($this->url_action)) { // no action defined: call the default index() method of a selected controller $this->url_controller->index(); } else { diff --git a/application/libs/helper.php b/application/libs/helper.php deleted file mode 100644 index 3897934..0000000 --- a/application/libs/helper.php +++ /dev/null @@ -1,57 +0,0 @@ - $value) { - - // check if named parameters (':param') or anonymous parameters ('?') are used - if (is_string($key)) { - $keys[] = '/' . $key . '/'; - } else { - $keys[] = '/[?]/'; - } - - // bring parameter into human-readable format - if (is_string($value)) { - $values[$key] = "'" . $value . "'"; - } elseif (is_array($value)) { - $values[$key] = implode(',', $value); - } elseif (is_null($value)) { - $values[$key] = 'NULL'; - } - } - - /* - echo "
[DEBUG] Keys:
";
-        print_r($keys);
-
-        echo "\n[DEBUG] Values: ";
-        print_r($values);
-        echo "
"; - */ - - $raw_sql = preg_replace($keys, $values, $raw_sql, 1, $count); - - return $raw_sql; - } - -} diff --git a/application/view/_templates/footer.php b/application/view/_templates/footer.php index 34d8820..86def1c 100644 --- a/application/view/_templates/footer.php +++ b/application/view/_templates/footer.php @@ -1,12 +1,13 @@ - +