framework simple-api-ssr
        A simple api-based server-side-rendering framework written in PHP.
    
            
                
                    
                    
                    
                    
                        
                            
    
        
        
            boxsnake/simple-api-ssr
            A simple api-based server-side-rendering framework written in PHP.
         
     
    
        
            -  Wednesday, May 23, 2018
-  by boxsnake
-  Repository
-  2 Watchers
-  2 Stars
-  6 Installations
 
    
        
                            - PHP
-  0 Dependents
-  0 Suggesters
-  0 Forks
-  0 Open issues
-  8 Versions
-  0 % Grown
 
 
    
        
            
    
    
    
 
 
 
 
 
 
 [![Gitter][*gitter]][@gitter], (*1)
[![Gitter][*gitter]][@gitter], (*1)
A simple api-based server-side-rendering framework written in PHP., (*2)
Table of Contents
Installation
# Install project
composer create-project boxsnake/simple-api-ssr <project_path> # via Composer
# Or, install latest project (may contain unstable features)
composer create-project boxsnake/simple-api-ssr <project_path> dev-master # (Option 1) via Composer
git clone https://github.com/boxsnake-php/simple-api-ssr <project_path>   # (Option 2) via Git
cd <project_path> # Change to project folder
composer install  # Install composer dependencies
npm install       # (Optional) For developers, install node.js dependencies
Project Architecture
├───example                     # JSON examples
├───node_modules                # Node.js dependencies
├───public                      # Web host root
│   ├───index.php
│   └───assets                  # (Suggestive) Assets
│       ├───js                  # (Suggestive) Javascript source
│       ├───css                 # (Suggestive) CSS source
│       └───image               # (Suggestive) Images
├───setting                     # Simple-API-SSR settings
│   └───engine_name.json        # Available template engine names
├───src
│   ├───pages                   # Templates
│   ├───config                  # API configurations
│   └───utils                   # Simple-API-SSR utilities
└───vendor                      # Composer dependencies
SSR Steps
- Fetch service_namefrom URLhttps://<host>:<port>/<pathname>?service=<service_name>.
- Load API config <service_name>.json.
- Fetch API data using config.
- Load template <service_name>.<template_engine_name>or<service_name>.<template_engine_name>.tpl.
- Render template with API results, and then print out.
Api Config
- 
Location: /src/config/
- 
Filename Scheme: <service_name>.json
- 
Example:
javascript
{
    "New": {                                  // This key is consistent with keys in results data
        "url": "https://fakeurl/fakepath/"    // (Required) API url
        "get": {                              // (Optional) Pass SSR GET params to API (via GET)
            "ssr_get_1": "api_get_1",
            "ssr_get_2": "api_get_2",
            ...
        },
        "post": {                             // (Optional) Pass SSR POST data to API (via POST)
            "ssr_post_1": "api_post_1",
            "ssr_post_2": "api_post_2",
            ...
        }
    },
    ...                                       // You can have multiple API sets
}
- 
Result Example:
javascript
{
    "New": {                // Key defined in config
                            // This object is API result for `https://fakeurl/fakepath`
        "Foo": "bar"
    },
    ...
}
Templates
- 
Location: /src/pages/
- 
Filename Scheme: <service_name>.<template_engine_name>.tpl
- 
Available Template Engines:
- _Smarty3_ (smarty)
- _Pug_ (pug)
- _Jade_ (jade) - Former name ofpug, currently not supported
 
- 
Predefined Variables:
- 
datafrom API results
- 
getfrom$_GET
- 
postfrom$_POST
 
Server Settings
- 
Host Path: <project_path>/public/
- (Option 1) Host Standalone: Apache / Nginx
- (Option 2) Host with API (using alias): Apache / Nginx
 
     
 
    
        
            
                                    
                        
                        
                        
                            dev-master
                            9999999-dev
                                                        
                                A simple api-based server-side-rendering framework written in PHP.
                                
                                                                     
                                    Sources
                                                                                                     
                                    Download
                                                                
                                
                                                                            MIT
                                    
                                
                                                                    The Requires
                                    
                                     
                                                                                            
                            
                                                                    
                                        
by 
                                                                                             
                                                                                                                                    Alex Fang
                                                                                    
                                    
                                
                            
                            
                                
                            
                         
                     
                                    
                        
                        
                        
                            v1.2.3
                            1.2.3.0
                                                        
                                A simple api-based server-side-rendering framework written in PHP.
                                
                                                                     
                                    Sources
                                                                                                     
                                    Download
                                                                
                                
                                                                            MIT
                                    
                                
                                                                    The Requires
                                    
                                     
                                                                                            
                            
                                                                    
                                        
by 
                                                                                             
                                                                                                                                    Alex Fang
                                                                                    
                                    
                                
                            
                            
                                
                            
                         
                     
                                    
                        
                        
                        
                            v1.2.2
                            1.2.2.0
                                                        
                                A simple api-based server-side-rendering framework written in PHP.
                                
                                                                     
                                    Sources
                                                                                                     
                                    Download
                                                                
                                
                                                                            MIT
                                    
                                
                                                                    The Requires
                                    
                                     
                                                                                            
                            
                                                                    
                                        
by 
                                                                                             
                                                                                                                                    Alex Fang
                                                                                    
                                    
                                
                            
                            
                                
                            
                         
                     
                                    
                        
                        
                        
                            v1.2.1
                            1.2.1.0
                                                        
                                A simple api-based server-side-rendering framework written in PHP.
                                
                                                                     
                                    Sources
                                                                                                     
                                    Download
                                                                
                                
                                                                            MIT
                                    
                                
                                                                    The Requires
                                    
                                     
                                                                                            
                            
                                                                    
                                        
by 
                                                                                             
                                                                                                                                    Alex Fang
                                                                                    
                                    
                                
                            
                            
                                
                            
                         
                     
                                    
                        
                        
                        
                            v1.2.0
                            1.2.0.0
                                                        
                                A simple api-based server-side-rendering framework written in PHP.
                                
                                                                     
                                    Sources
                                                                                                     
                                    Download
                                                                
                                
                                                                            MIT
                                    
                                
                                                                    The Requires
                                    
                                     
                                                                                            
                            
                                                                    
                                        
by 
                                                                                             
                                                                                                                                    Alex Fang
                                                                                    
                                    
                                
                            
                            
                                
                            
                         
                     
                                    
                        
                        
                        
                            v1.1.1
                            1.1.1.0
                                                        
                                A simple api-based server-side-rendering framework written in PHP.
                                
                                                                     
                                    Sources
                                                                                                     
                                    Download
                                                                
                                
                                                                            MIT
                                    
                                
                                                                    The Requires
                                    
                                     
                                                                                            
                            
                                                                    
                                        
by 
                                                                                             
                                                                                                                                    Alex Fang
                                                                                    
                                    
                                
                            
                            
                                
                            
                         
                     
                                    
                        
                        
                        
                            v1.1.0
                            1.1.0.0
                                                        
                                A simple api-based server-side-rendering framework written in PHP.
                                
                                                                     
                                    Sources
                                                                                                     
                                    Download
                                                                
                                
                                                                            MIT
                                    
                                
                                                                    The Requires
                                    
                                     
                                                                                            
                            
                                                                    
                                        
by 
                                                                                             
                                                                                                                                    Alex Fang
                                                                                    
                                    
                                
                            
                            
                                
                            
                         
                     
                                    
                        
                        
                        
                            v1.0.0
                            1.0.0.0
                                                        
                                A simple api-based server-side-rendering framework written in PHP.
                                
                                                                     
                                    Sources
                                                                                                     
                                    Download
                                                                
                                
                                                                            MIT
                                    
                                
                                                                    The Requires
                                    
                                     
                                                                                            
                            
                                                                    
                                        
by 
                                                                                             
                                                                                                                                    Alex Fang