简体   繁体   中英

Using PHP Slim Framework

I want to use Slim for PHP in my project for the first time. The manual says:

Install composer in your project:

curl -s https://getcomposer.org/installer | php
Create a composer.json file in your project root:

{
    "require": {
        "slim/slim": "2.*"
    }
}
Install via composer:

php composer.phar install
Add this line to your application’s index.php file:

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

I'm afraid, I don't get it. Where should the commands "curl" and "php" be used? I only access my webspace through Filezilla. How can I then apply such a command?

What do those steps do anyway? Sadly, the manual is not helpful at all.

See http://www.slimframework.com/install :

MANUAL INSTALL Download and extract the Slim Framwork into your project directory and require it in your application's index.php file. You'll also need to register Slim's autoloader.

<?php
require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();

And there are links to zip-files.

If you're getting started on slim i'd definitely suggest that you get a good IDE that will guide you through the whole process. When I started the slim framework, I came across an IDE by jetbrains called PHPStorm. It makes everything so easy by doing most of the stuff you listed for you...

  1. download and install PHPStorm https://www.jetbrains.com/phpstorm/download/

  2. download and install Composer https://getcomposer.org/download/ so PHPStorm can use it.

  3. get to the part where you start PHPStorm.

  4. go to File > new Project > Composer Project and follow the motions.

It'll create all the files you listed. Then all you have to do is look and learn what it all means.

Composer is basically a package manager, you basically open a cmd and navigate to the place you want to create you PHP Slim application and type some composer commands to install package files in that folder. Composer then gets the packages and puts them in a directory called 'vendor' in that project folder of yours.

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

that's basically a config file that either you or composer will create in the same file also.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM