Slim installation and use

Source: Internet
Author: User
Tags php framework

I've been doing things with Backbone.js recently, because I'm involved in rest services and need background support, PHP is selected here. Slim is a framework for PHP.

It seems that the domestic article on the introduction of relatively few, in the installation of slim in the process of some problems, after three or four hours, the final solution. A simple summary of this, hoping to save time for later learners. Slim IntroductionFeature List
    • HTTP Routing
    • Named routes
    • Route passing
    • Route redirects
    • Route halting
    • Middleware & Hooks
    • Custom views
    • HTTP Caching
    • Signed Cookies
    • Custom 404 Page
    • Custom page
    • Error Handling
    • Logging
System Requirements
    • Web Server (URL rewrite module recommended)
    • PHP >= 5.3
    • Libmcrypt > 2.4.x (if using encrypted cookies)
Of course you can go to the official website, http://www.slimframework.com/specific use of the document you can go to http://docs.slimframework.com/abroad there is an article can also refer to HTTP// WILLISBORED.COM/2011/04/04/TUTORIAL-SLIM-PHP-VIEW-TEMPLATES/1, first of all we first illustrated how to install slim to download Slim folder
2, second, to understand that this is the PHP Framework, you need to configure the PHP runtime environment, the choice here Wampserver version 2.2 its PHP version >5.3 can run Slim. Download Wampserver, follow the prompts step by step by default installation is possible. Run after installation

about how to install the configuration Wampserver, Baidu has a detailed article http://wenku.baidu.com/view/d6107823192e45361066f53c.html

3, again to support the Web Serive,url can be rewritten, enable the Apache Mod_rewrite module in the Conf directory httpd.conf file found LoadModule rewrite_module modules/mod_ Rewrite.so the # in front of this line. 2. Enable Options FollowSymLinks and allowoverride all in the directory where you want to support URL rewirte to search in the httpd.conf file locate here options FollowSymLinks Al Lowoverride None Order Deny,allow deny from all reference this write d:/wamp/www/slimtwigexample because I set the localhost to be d:/wamp/www/, New Folder Slimtwigexample under WWW, unzip the downloaded slim file to this folder. Options Indexes followsymlinksallowoverride allorder allow,denyallow from All4, let's start writing code, modify index.php page tail $app->run ( ); Comment out this sentence, add the following statement, adding a rest service $app2=new \slim\slim (); $app 2->get ('/hello/:name ', function ($name) {echo ' Hello '. '. $name;}); $app 2->run (); After editing, restart Apache, available in Apache->service->restart. Then enter Http://localhost/SlimTwigExample/hello/Fany in the browser and the Hello Fany will be displayed on the page

Because I'm a cookie, I don't take into account the third condition behind it. at this point, Slim can be used. There is a problem with PHP version in using Wampserver, here you can use the following method to approximate. Original link to manually install multiple versions of PHP on Wampserver

Wampserver is a software that integrates Php/mysql/apache and other applications (such as phpmyadmin/xdebug[, perhaps not]), and its most beloved feature is not to simplify the installation configuration of Php/mysql/apache, Instead, we can switch between different versions of the installed Php/mysql/apache with just a few clicks. PHP programmers are most aware of the need for different versions of PHP.

Wampserver version menu (Apache, PHP, MySQL each have a version menu), there is a Get more ... Connect, click on it to download the version you need on the official website, the installation is automated, very simple. What if we don't have the version we need? Hands-on, clothed!

To manually install a new version of PHP, simply follow these steps:

  1. Download the version of PHP you want to install. Since the use of wampserver, it is of course the Download window version of the ZIP package: http://windows.php.net. Unzip to Wamp's installation directory \bin\php\php5.2.17. Here take 5.2.17 as an example.
  2. Enter Wamp's installation directory \bin\php\php5.2.17 directory, copy from Php.ini-dist or php.ini-recommended, rename to php.ini, Adapt to modify the php.ini configuration (such as Extension_dir), and then copy one point from php.ini and rename it to Phpforapache.ini.
  3. Copies a copy of wampserver.conf from an existing version directory. For example, when I install Wampserver, I already have php5.3.0, in Wamp's installation directory \bin\php\php5.3.0 directory to copy wampserver.conf to wamp installation directory \ bin\php\php5.2.17.
  4. Modify WAMP configuration file: Enterinstallation directory for Wamp, open Wampmanager.ini with the IDE or Notepad (preferably a notepad with line numbers, such as editplus, etc.), and navigate to 335 rows, usually in this line [phpversion], if not, find it nearby. Copy the following line: Type:item; Caption: "5.3.0"; Action:multi; actions:switchphp5.3.0
    Insert in front of this line and modify to Type:item; Caption: "5.2.17"; Action:multi; actions:switchphp5.2.17 re-copying [switchPhp5.3.0]
    Action:service; Service:wampapache; Serviceaction:stop; Flags:ignoreerrors waituntilterminated
    Action:run; FileName: "installation directory for Wamp/bin/php/php5.3.0/php-win.exe "; Parameters: "switchphpversion.php 5.3.0"; Workingdir: "installation directory for Wamp/scripts "; flags:waituntilterminated
    Action:run; FileName: "installation directory for Wamp/bin/php/php5.3.0/php-win.exe "; Parameters: "-C. Refresh.php "; Workingdir: "installation directory for Wamp/scripts "; flags:waituntilterminated
    Action:run; FileName: "NET"; Parameters: "Start Wampapache"; Showcmd:hidden; flags:waituntilterminated
    Action:resetservices
    Action:readconfig; Before inserting this paragraph, and amended to
    [switchphp5.2.17]
    Action:service; Service:wampapache; Serviceaction:stop; Flags:ignoreerrors waituntilterminated
    Action:run; FileName: "installation directory for Wamp/bin/php/php5.3.0/php-win.exe "; Parameters: "switchphpversion.php5.2.17"; Workingdir: "installation directory for Wamp/scripts "; flags:waituntilterminated
    Action:run; FileName: "installation directory for Wamp/bin/php/php5.3.0/php-win.exe "; Parameters: "-C. Refresh.php "; Workingdir: "installation directory for Wamp/scripts "; Flags:waituntilterminatedAction:run; FileName: "NET"; Parameters: "Start Wampapache"; Showcmd:hidden; flags:waituntilterminated
    Action:resetservices
    Action:readconfig;
  5. Exit Wampserver, and then restart. Complete.

With these 5 steps, you can complete any version of PHP installation.

Slim installation and use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.