Step 1 : Download and run Composer-Setup.exe
Step 2 : Open Command Prompt on Windows and Run Script
-Download the installer to the current directory
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
-Verify the installer SHA-384 which you can also cross-check here
php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
-Run the installer
php composer-setup.php
-Remove the installer
php -r "unlink('composer-setup.php');"
-----------------------After Install and Telling Message-------------------------
All settings correct for using Composer
Downloading 1.1.3...
Composer successfully installed to: C:\Users\suttipong\composer.phar
Use it: php composer.phar
-Update Composer
php composer.phar self-update
HOW TO USE COMPOSER
- Introduction
- composer.json: Project Setup
- Installing Dependencies
- composer.lock - The Lock File
- Packagist
- Autoloading
Example : Create Project laravel with Composer :
composer create-project laravel/laravel exampleProject --prefer-dist
Problems 1 : How to import vendor folder
If you have the problem (vendor/autoload.php) in your php file it's has not work.
Autoload File has not work and it show message in the windows
How to....
Step 1 : copy composer.phar file into your folder in server and you write the command
Step 2 : From this command. It has the generate file (vendor folder, composer.lock) in your folder
Problems 2 : class slim/slim not found with composer
You will must have to write script for test.
-How to test Autoload of Slim
<?php
require 'vendor/autoload.php'; //call Autoload PHP Page
$app = new \Slim\Slim(); //call Slim PHP class
$app->get('/', function () { //get root path
echo "Hello World!";
});
$app->run();
-How to test Slim class
<?php
//require 'Slim/Slim.php';
require 'vendor/slim/slim/Slim/Slim.php';
$app = new Slim();
$app->get('/hello', 'hello'); //call hello page and call method hello
$app->get('/hello/:name', function ($name) {
echo "Hello, $name";
});
$app->run();
function hello() {
echo "Hello World.";
}
?>
Reference :
Problems 3 : xampp server 404 page not found
index.php
<?php
// Pull in our bootstrap file.
require_once '../src/ProjectName/bootstrap.php';
$app->run();
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME}% !-f
RewriteCond %{REQUEST_FILENAME}% !-d
RewriteRule ^ index.php [QSA,L]
-Open .htaccess File to Edit
Reference :
http://stackoverflow.com/questions/12343466/always-get-404-error-in-slim-framework-when-omitting-index-php-in-url
bootstrap.php
<?php
require_once '../vendor/autoload.php';
$app = new \Slim\App();
require_once 'Routes.php';
example.php
$app->get('/example/{name}', function ($request, $response, $args) {
echo 'Hello ' . $args['name'];
}
Problems 4 : How to require function between class with using root path in PHP folder
/A
foo.php
tar.php
B/
bar.php
If you call foo.php (ex: http://example.com/foo.php), the working directory will be /A/. If you call bar.php (ex: http://example.com/B/bar.php), the working directory will be /A/B/.
foo.php call bar.php
<?php
require_once( 'B/bar.php' );
?>
bar.php call tar.php
<?php
require_once( 'tar.php');
?>
--------------------------------------------------------------------
URL :1.) Composer - Dependency Management for PHP
https://github.com/kullawattana/composer
2.) Slim Framework 3 Skeleton Application
https://github.com/slimphp/Slim-Skeleton
3.) Download Composer for Create laravel and Slim Project
https://getcomposer.org/download/
4.) Laravel Project
https://laravel.com/docs/4.2/quick
5.) Install Composer on Windows
https://www.youtube.com/watch?v=ZocYVPP3nQY
6.) CURL
http://php.net/manual/en/book.curl.php