-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.html
57 lines (53 loc) · 12.3 KB
/
install.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Installation | Pinatra</title>
<meta name="description" content="A PHP verison of Sinatra: a DSL for quickly creating web applications in PHP with minimal effort.">
<link rel="preload" href="/assets/css/0.styles.73742341.css" as="style"><link rel="preload" href="/assets/js/app.35633900.js" as="script"><link rel="preload" href="/assets/js/7.490e94d8.js" as="script"><link rel="prefetch" href="/assets/js/4.dd1ee4a1.js"><link rel="prefetch" href="/assets/js/2.9834f0cc.js"><link rel="prefetch" href="/assets/js/3.2b86a6bc.js"><link rel="prefetch" href="/assets/js/5.ad87e3bc.js"><link rel="prefetch" href="/assets/js/6.7a49fda2.js"><link rel="prefetch" href="/assets/js/8.3b2a41b2.js"><link rel="prefetch" href="/assets/js/9.cfda04a6.js"><link rel="prefetch" href="/assets/js/10.20f55d86.js"><link rel="prefetch" href="/assets/js/11.fbd446e0.js"><link rel="prefetch" href="/assets/js/12.7418dee3.js"><link rel="prefetch" href="/assets/js/13.111e6ced.js"><link rel="prefetch" href="/assets/js/14.78258348.js"><link rel="prefetch" href="/assets/js/15.73297d5e.js"><link rel="prefetch" href="/assets/js/16.63b4556e.js"><link rel="prefetch" href="/assets/js/17.c9391c34.js"><link rel="prefetch" href="/assets/js/18.584449ed.js"><link rel="prefetch" href="/assets/js/19.c8dececa.js"><link rel="prefetch" href="/assets/js/vendors~docsearch.41d79f37.js">
<link rel="stylesheet" href="/assets/css/0.styles.73742341.css">
</head>
<body>
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><!----> <span class="site-name">Pinatra</span></a> <div class="links" style="max-width:nullpx;"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="https://github.com/Pinatra/Pinatra" target="_blank" rel="noopener noreferrer" class="nav-link external">
Source
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">Languages</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/install.html" class="nav-link router-link-exact-active router-link-active">English</a></li><li class="dropdown-item"><!----> <a href="/zh/install.html" class="nav-link">简体中文</a></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <div class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="https://github.com/Pinatra/Pinatra" target="_blank" rel="noopener noreferrer" class="nav-link external">
Source
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">Languages</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/install.html" class="nav-link router-link-exact-active router-link-active">English</a></li><li class="dropdown-item"><!----> <a href="/zh/install.html" class="nav-link">简体中文</a></li></ul></div></div> <!----></nav> <ul class="sidebar-links"><li><div class="sidebar-group first"><p class="sidebar-heading open"><span>Guide</span> <!----></p> <ul class="sidebar-group-items"><li><a href="/" class="sidebar-link">Introduction</a></li><li><a href="/install.html" class="active sidebar-link">Installation</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/install.html#environment-require" class="sidebar-link">Environment require</a></li><li class="sidebar-sub-header"><a href="/install.html#details" class="sidebar-link">Details</a></li></ul></li><li><a href="/routing.html" class="sidebar-link">Routing</a></li><li><a href="/controller.html" class="sidebar-link">Controller</a></li><li><a href="/view.html" class="sidebar-link">Views</a></li><li><a href="/model.html" class="sidebar-link">Model</a></li><li><a href="/kernel.html" class="sidebar-link">Kernel details</a></li><li><a href="/benchmark.html" class="sidebar-link">Benchmark</a></li></ul></div></li></ul> </div> <div class="page"> <div class="content"><h1 id="installation"><a href="#installation" aria-hidden="true" class="header-anchor">#</a> Installation</h1> <h2 id="environment-require"><a href="#environment-require" aria-hidden="true" class="header-anchor">#</a> Environment require</h2> <ul><li>PHP > 7.0</li> <li>Composer</li></ul> <h3 id="composer"><a href="#composer" aria-hidden="true" class="header-anchor">#</a> Composer</h3> <p>Composer is the most popular PHP package manager, and there are plenty of open source software in the community for you to choose from.</p> <h2 id="details"><a href="#details" aria-hidden="true" class="header-anchor">#</a> Details</h2> <p>Pinatra is the first PHP framework to do true hands-off, which itself is only available as an library, but provides sophisticated routing capabilities and a detailed MVC architecture.</p> <p>Here is the "Step by Step" tutorial:</p> <h3 id="make-a-new-project-folder"><a href="#make-a-new-project-folder" aria-hidden="true" class="header-anchor">#</a> Make a new project folder</h3> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">mkdir</span> blog
</code></pre></div><h3 id="composer-initialization"><a href="#composer-initialization" aria-hidden="true" class="header-anchor">#</a> composer initialization</h3> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">cd</span> blog
composer self-update
composer init
</code></pre></div><p>Then press Enter until <code>Search for a package</code>, type <code>pinatra/framework</code> and press Enter. When you get <code>version of the constraint to require (or leave blank to use the latest version)</code>, type <code>~0.0</code>, then continue press Enter all the way until the end of the interaction.</p> <p>At this point, executing <code>ls -a</code> appears as shown below:</p> <p><img src="/assets/img/1.1b132699.jpg" alt="ls"></p> <h3 id="view-composer-json"><a href="#view-composer-json" aria-hidden="true" class="header-anchor">#</a> View composer.json</h3> <p>Now the content of composer.json should be as follows:</p> <div class="language-json extra-class"><pre class="language-json"><code><span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"user/blog"</span><span class="token punctuation">,</span>
<span class="token property">"require"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"pinatra/framework"</span><span class="token operator">:</span> <span class="token string">"~0.0"</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token property">"authors"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"JohnLui"</span><span class="token punctuation">,</span>
<span class="token property">"email"</span><span class="token operator">:</span> <span class="token string">"[email protected]"</span>
<span class="token punctuation">}</span>
<span class="token punctuation">]</span>
<span class="token punctuation">}</span>
</code></pre></div><h3 id="download-all-composer-packages"><a href="#download-all-composer-packages" aria-hidden="true" class="header-anchor">#</a> Download all composer packages</h3> <p>Excuting shell command:</p> <div class="language-bash extra-class"><pre class="language-bash"><code>composer update
</code></pre></div><p>At this point you should get the vendor folder and expand it as shown below:</p> <p><img src="/assets/img/2.e77573d4.jpg" alt="vendor"></p> <h3 id="create-index-php"><a href="#create-index-php" aria-hidden="true" class="header-anchor">#</a> Create index.php</h3> <p>This project's document root folder should be at the same level as the vendor, which is a security requirement. Create a new public folder:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">mkdir</span> public
<span class="token function">cd</span> public
</code></pre></div><p>Create a new index.php file:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">touch</span> index.php
</code></pre></div><p>Then fill it up with the following code:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token operator"><</span>?php
require __DIR__.<span class="token string">'/../vendor/autoload.php'</span><span class="token punctuation">;</span>
get<span class="token punctuation">(</span><span class="token string">'hi'</span>, function<span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">echo</span> <span class="token string">"I am Pinatra framework!"</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre></div><h3 id="use-the-single-threaded-built-in-web-server-of-php-to-get-our-website-live"><a href="#use-the-single-threaded-built-in-web-server-of-php-to-get-our-website-live" aria-hidden="true" class="header-anchor">#</a> Use the single-threaded built-in web server of PHP to get our website live!</h3> <p>Make sure that the current path of the command line is under the public folder, and then run the following command:</p> <div class="language-bash extra-class"><pre class="language-bash"><code>php -S 0.0.0.0:8000
</code></pre></div><h3 id="view-results"><a href="#view-results" aria-hidden="true" class="header-anchor">#</a> View results</h3> <p>Visit <code>http://0.0.0.0:8000/hi</code>, if your results are as shown below, you are successful!</p> <p><img src="/assets/img/3.b07797e6.jpg" alt="success"></p></div> <div class="page-edit"><!----> <div class="last-updated"><span class="prefix">Last Updated: </span> <span class="time">9/14/2018, 1:15:31 PM</span></div></div> <div class="page-nav"><p class="inner"><span class="prev">
←
<a href="/" class="prev router-link-active">
Introduction
</a></span> <span class="next"><a href="/routing.html">
Routing
</a>
→
</span></p></div> </div> <!----></div></div>
<script src="/assets/js/7.490e94d8.js" defer></script><script src="/assets/js/app.35633900.js" defer></script>
</body>
</html>