Install Slim Framework and Write Your First
|Shares :

Install Slim Framework and Write Your First "Hello World"

You want to create a simple Website but you don't want to start from scratch or a complex Framework ? You need to try Slim Framework

Installing Slim Framework would be much easier if we're using Composer.

Create a folder (your project folder) in your Web server (htdocs for apache users). for example we create "slim" . create a new file "composer.json" inside slim and type this : 

{
    "require": {
        "slim/slim": "2.*"
    }
}

Open you terminal and make sure its under slim folder for example

root@AcerXtimeline:/opt/lampp/htdocs/slim#

now type : composer install or php composer.phar install (depending on how you install the composer). If you follow this Composer Install Tutorial, you just need the first option

 root@AcerXtimeline:/opt/lampp/htdocs/slim# composer install

You'll see the process

Loading composer repositories with package information
Installing dependencies (including require-dev)

  - Installing slim/slim (2.4.3)
    Downloading: 100%         
Writing lock file
Generating autoload files


Once its done, create index.php and type : 

require "vendor/autoload.php";

$app = new \Slim\Slim();
$app->get("/",function(){
    echo "Hello World";
});
$app->run();


Also edit .htaccess file :

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L] 


so you can now open it in Browser : 

http://localhost/slim


Tags : #install #php #slim #framework


SHARES :


Budy K's Avatar

Sains & Teknologi Enthusiast, Software Developer. Check my profile!
> 75% komen akan dibalas. Mohon sabar ya. Simpan halaman ini dan cek kembali lagi

Comments

* Email will not be published


    Privacy .ToS .Contact Us
    © 2017 Teknosains