Search This Blog

Tuesday, June 14, 2016

Slim Framework - Global PHP reference Steps Installation

1. Download composer_setup.exe for windows
install it -> select php.exe from xampp/php/


2 Copy composer.phar from C:\ProgramData\ComposerSetup\bin [hidden folder] to D:\php\ [apache root directory]

3. type to install vendor folder [slim setups]
    D:\php> php composer.phar require slim/slim

4. create your root folder (ex: test) and in your index.php..
    add ../vendor/autoload.php

ex:index.php
 
   
    use \Psr\Http\Message\ServerRequestInterface as Request;
    use \Psr\Http\Message\ResponseInterface as Response;

    require '../vendor/autoload.php';

    $app = new \Slim\App;
    $app->get('/', function (Request $request, Response $response) {
         $response->getBody()->write("Welcome");
    });

    $app->get('/home/{name}', function (Request $request, Response $response) {
        $name = $request->getAttribute('name');
        $response->getBody()->write("Hello, $name");
   
        return $response;
    });
    $app->run();




5. run apache and in browser    http://localhost:8888/test/




Slim Framework - PHP Install Steps

1. Download composer_setup.exe for windows
install it -> select php.exe from xampp/php/

2. create a folder where your xampp root folder
    Create folder
    D:\works\beyond\php\test
    D:\works\beyond\php\test\src
    D:\works\beyond\php\test\src\public


2.1 Copy composer.phar from C:\ProgramData\ComposerSetup\bin [hidden folder] to X:\test\src

//install slim
3. X:\test\src> php composer.phar require slim/slim

//extra dependencies
4. X:\test\src> composer install

5. SVN commit with vendor folder as ignore. that will take care by composer.phar composer.lock composer.json.

6. Create a file X:\test\src\public\index.php
    write your program.
   

7. RUN xampp and type http://localhost:8888/test/src/public/

FOR REST API
*************

1. Go to xampp/apache/conf/httpd.conf change to doc root/directory to D:/test/public
2. restart the apache
3. api url. http://localhost:8888/hello/vijay

Hit Counter


View My Stats