Someline Starter is a PHP framework for quick building Web Apps and Restful APIs, with modern PHP design pattern foundation.

Overview

Someline Starter PHP Framework

Tested and used in production by Someline Inc.

Latest Version on Packagist Software License

Someline Starter is a PHP framework for quick building Web Apps and Restful APIs, with modern design pattern foundation.

It is built on top of popular Laravel 5.8 framework, Vue.js 2.6, Restful API, Repository Design, OAuth2, JWT, Unit Tests, isolated front-end and back-end layer.

Someline Starter is born for 3 reasons:

  1. Quick web application starter without the need to build from scratch using Laravel.

  2. Isolated front-end and back-end layer using Restful API.

  3. Introducing modern design pattern, which have a better foundation when starting, for PHP projects.

See In Action

Someline Starter Demo

Frontend with Vue.js and displaying data via Restful API

Email: [email protected]

Password: Abc12345

See In Video

Watch the video tutorial from below.

YouTube: https://youtu.be/6_lxJNX0Qe0

Framework Overview

Someline Starter is suitable for Restful API oriented projects.

The Restful APIs as a backend layer which provide simple unified interfaces for frontend: Web and Mobile apps.

It utilized Laravel Passport to authenticate protected resources.

It also provides Unit Tests for API testing and framework testing.

It is shipped with Angulr Theme and features in every part that you can easily reference.

It is fully utilised Repository Design pattern.

Out-of-box Components

If you are not familiar with any of these packages, you are recommended to get to know them as they are really helpful when you needed.

Framework

Foundation

Core

Authentication

Theme

Frontend

  • Vue.js Reactive Components for Modern Web Interfaces

Get Started

Make sure you have already installed PHP 7.1 and composer.

You can get started either option A or B:

A. Get started via composer

Under working folder, run the command:

composer create-project --prefer-dist someline/someline-starter someline-starter

A.1. Add to a git repository (When Needed)

Change https://github.com/username/repository-name.git to your own git repository address.

cd someline-starter

git init
git add .
git commit -m 'Initial commit'

git remote add origin https://github.com/username/repository-name.git
git push -u origin master

B. Get started via cloning repository

Clone this project to your working folder and open the directory:

git clone https://github.com/someline/someline-starter

B.1. Add to a git repository (When Needed)

Change https://github.com/username/repository-name.git to your own git repository address.

cd someline-starter
rm -rf .git

git init
git add .
git commit -m 'Initial commit'

git remote add origin https://github.com/username/repository-name.git
git push -u origin master

Installation

Development Requirements

Install Essentials

Open someline-starter folder (Optional, run only when you are not inside the project root folder)

cd someline-starter

All these commands should be executed under the root of someline-starter project

Install composer dependencies

composer install

Install npm dependencies using Yarn dependency management (suggested)

Note: This command should be outside homestead environment. Also, you can still use npm install if you want.

yarn install

Install bower dependencies

bower install

Set-up Laravel, after these commands, please change .env file for your own environment settings

sudo cp .env.example .env
sudo chmod -R 777 storage bootstrap/cache
php artisan key:generate

Database & Seeding

You need to create a Database e.g. someline_starter with Encoding utf8mb4 and Collation utf8mb4_unicode_ci.

MySQL Query:

CREATE DATABASE `someline_starter` DEFAULT CHARACTER SET = `utf8mb4` DEFAULT COLLATE = `utf8mb4_unicode_ci`;

Change database config in .env file to the match the database that your just created.

After having database configuration setup, you can now do migrations and seeding.

php artisan migrate

php artisan db:seed

Install Laravel Passport with encryption keys to generate secure access tokens.

php artisan passport:install

When deploy in server:

sudo chown www-data:www-data storage/oauth-*.key
sudo chmod 600 storage/oauth-*.key

Ready to go

Until this point, you should be able to visit the home page.

For example, if you have set the domain: http://someline-starter.sl/.

Just visit: http://someline-starter.sl/

It should prompt you for login, use:

[email protected]
Abc12345

You are free to change the seeding account information from the file: database/seeds/UsersTableSeeder.php

You are done. Yeah!

Explore and start to build on top of it.

Development Process and Flow

Essential Knowledge

You will need to know, read and understand fowllowing before you can start build on top of these.

We recommend use PHPStorm IDE to build and develop your projects.

Namespace

The default namespace for app/ folder is Someline.

It is NOT recommended to change the namespace, if you are not familiar with namespace of Someline Starter as the Someline namespace is used heavily within whole project.

However, you can still change it if you know how what you are doing, because some namespaces required manually changing.

To change namespace to your preference:

php artisan app:namespace YourApp

BaseClass

In order to utilize all features provided by Someline Starter, you should extended the Class from BaseClass (if there has one), e.g. BasePresenter, BaseController, etc.

Models

All models are located under app/Models/ folder.

User Model under folder app/Models/Foundation/ is created by default with primary key user_id, you should not change this class heavily because it is used almost everywhere within whole project. You can use global function auth_user() to access currently logged in user.

Every model should extend Someline/Models/BaseModel which has a observer Someline/Observers/BaseModelObserver that you can utilize all model events within the Model, e.g. onCreating, onCreated, onUpdating, onDeleting, etc.

When creating new model, you should do it using command to auto generate related Repository classes.

php artisan starter:entity Post

Web Http

All Web related files are located under app/Http/ folder.

Web Routes are defined in file routes/web.php

Web Controllers are defined in folder app/Http/Controllers/

Restful API

All API related files are located under app/Api/ folder.

API Routes are defined in file routes/api.php

API Controllers are defined in folder app/Api/Controllers/

When you create APIs, you need to test them before you can use it. You should test all APIs using Unit Tests provided or create new Unit Tests. Not recommended to test using Browser or Postman, etc.

Repository Pattern

All repository related files are located under app/ with specific types as parent folders.

Repositories: app/Repositories/

Repositories Eloquent: app/Repositories/Eloquent/

Repositories Interface: app/Repositories/Interfaces/

Repositories Criteria: app/Repositories/Criteria/

Presenters: app/Presenters/

Transformers: app/Transformers/

Validators: app/Validators/

Resouces

Angulr Styles and Scripts: resources/assets/angulr/

Angulr with Blade views: resources/views/angulr/

Vuejs: resources/assets/js/

Less styles: resources/assets/less/app.less

Sass styles: resources/assets/sass/app.scss

When made changes in scripts, styles, you will need to run the command.

In development, run:

yarn run dev

In development and watching assets for changes, run:

yarn run watch

In production, run:

yarn run production

When you changed theme files, run:

yarn run theme

API and Unit Tests

Note:

You may need to change the local service configs under dev environment from config/rest-client.php to fit your local development configurations.

Also change the value of API_TEST_CLIENT_SECRET in .env file to the secret value of Password Grant Client record in oauth_clients table.

Unit Tests: tests/

API Unit Tests: tests/Api/

Debug and Clockwork

View all requests and request information from file storage/clockwork.sqlite

OAuth Web Support

OAuth HTTP URL: http://someline-starter.sl/console/oauth

Web Log Viewer

Log Viewer HTTP URL: http://someline-starter.sl/console/logs

Database

We recommend to use migrations for database structure and seeding.

Directly changing from database or not follow migrations is strongly NOT recommended.

Flow of creating database migrations:
  1. Create a migration file (Auto generated when use php artisan starter:entity), under folder database/migrations/

  2. Add essential columns to migration file (Auto generated when use php artisan starter:entity):

You are recommended to use tablename_id format as primary incremental key, for example, for table posts, you need to use post_id, and when this become a foreign key, you should keep the same name in other table post_id.

$table->increments('post_id');

You are also recommended to use the user_id field in all tables, for example, use user_id as staff id instead of staff_id in company_staffs table. If there are no meaning for user_id in certain tables, you should still put user_id field in case for future usage. So, you need to use it smartly to fit your table scenarios accordingly. And, similarly, you may optionally want to add a related_user_id field to indicate certain record is related to a user depends on your own needs.

The following columns are always required by BaseModel:

$table->unsignedInteger('user_id')->index();

$table->unsignedInteger('created_by')->nullable();
$table->timestamp('created_at')->nullable();
$table->ipAddress('created_ip')->nullable();
$table->unsignedInteger('updated_by')->nullable();
$table->timestamp('updated_at')->nullable();
$table->ipAddress('updated_ip')->nullable();

And remove timestamps():

// $table->timestamps();

Finally, the table blue print should be looks like, e.g. in posts table:

$table->increments('post_id');
$table->unsignedInteger('user_id')->index();

// Adding more table related fields here...

$table->unsignedInteger('created_by')->nullable();
$table->timestamp('created_at')->nullable();
$table->ipAddress('created_ip')->nullable();
$table->unsignedInteger('updated_by')->nullable();
$table->timestamp('updated_at')->nullable();
$table->ipAddress('updated_ip')->nullable();
  1. Add factory support, under file database/factories/ModelFactory.php

  2. Create seeding support, under folder database/seeds/

Refresh Database Migrations and Seeding

When you added or changed to migrations or seeds files, or you just simply want to refresh everything in database:

php artisan migrate:refresh --seed

License

The Someline Starter framework is open-sourced software licensed under the MIT license.

Comments
  • Specified key was too long in initial migration

    Specified key was too long in initial migration

    Hi, I'm getting this error when I run migrate.

    While installing on mysql 5.5.42 encoding utf8mb4 collation utf8mb4_unicode_ci

    Migration table created successfully.
    
    
      [Illuminate\Database\QueryException]
      SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `oauth_client_endpoints` add unique `oauth_cli
      ent_endpoints_client_id_redirect_uri_unique`(`client_id`, `redirect_uri`))
    
    
    
      [PDOException]
      SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
    
    opened by jessynt 8
  • Error while running php artisan route:list

    Error while running php artisan route:list

    Hi,

    i have this error while running the command php artisan route:list :

    [ReflectionException]
    Class Someline\Http\Controllers\HomeController does not exist

    Solution :

    • Remove the line from Http/routes.php file
    • Add a HomeController to the project

    Another issue : I dont see Api routes in the result of that command, why ?

    Thanks

    opened by enimiste 7
  • Getting error while

    Getting error while "php artisan migrate"

    Hi,

    Getting Error on php artisan migrate command

    only 3 tables are getting created migrations, password_resets, users;

    here is output file of php artisan migrate > artisan_migrate.txt full path is removed in output

    artisan_migrate.txt

    Steps i followed

    • composer install
    • cp .env.example .env
    • chmod -R 777 storage bootstrap/cache
    • php artisan key:generate
    • php artisan migrate ( database already created and .env configured )

    system environment

    • PHP: 7.1.18
    • MySQL: 5.7.22
    • SQLite installed
    Migration table created successfully.
    
       Illuminate\Database\QueryException  : SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table `password_resets` add index `password_resets_email_index`(`email`))
    
      at vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
        660|         // If an exception occurs when attempting to run a query, we'll format the error
        661|         // message to include the bindings with SQL, which will make this exception a
        662|         // lot more helpful to the developer instead of just the database's errors.
        663|         catch (Exception $e) {
      > 664|             throw new QueryException(
        665|                 $query, $this->prepareBindings($bindings), $e
        666|             );
        667|         }
        668|
    
      Exception trace:
    
      1   Doctrine\DBAL\Driver\PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes")
          vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:143
    
      2   PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes")
          vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:141
    
      Please use the argument -v to see more details.
    
    
    opened by GaneshKandu 6
  • Migration error

    Migration error

    Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL : alter tablepassword_resetsadd indexpassword_resets_email_index(email))

    Using MariaDB 10.1

    opened by jebog 5
  • Unit Testing Someline V0.3.4 - Failed to get access token.

    Unit Testing Someline V0.3.4 - Failed to get access token.

    I did tried to setup the version 0.3.4 of Someline Starter but when i run Unit test i get the follow error:

    Response STATUS CODE is 401:
    Array
    (
        [error] => invalid_client
        [message] => Client authentication failed
    )
    
    Failed to get access token for grant type [password]!
    

    I run all the commands, the oauth_* tables are populated but i get the error Failed to get access token...

    I'm trying to run the pre-built test of Users. Too difficult at the moment write other tests... :)

    opened by mistre83 4
  • How to change base_uri for Unit Test

    How to change base_uri for Unit Test

    I've setup the new version of Someline (Laravel 5.3) and it point to http://someline-starter-demo.app but when i run unit test i get this error:

    Connection timeout:
    REST CLIENT SERVICE: local, ENVIRONMENT: dev
    REST CLIENT BASE URI: http://someline-starter.app/
    

    I'm looking the video tutorial (the new video version, that is related to Laravel 5.2) and this show how to modify the base_uri in BaseApiTestCas.php

    But in this new version the structure has changed and i dont find how to change that URI.

    opened by mistre83 4
  • Issue when runing php artisan migrate

    Issue when runing php artisan migrate

    Hi,

    Thanks for this greate framework. i'm watching your tutorial on Youtube. But when i want to migrate the database using the command php artisan migrate --seed i had this error message : [Illuminate\Database\QueryException] SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'oauth_client_endpoints' already exists (SQL: cr eate tableoauth_client_endpoints(idint unsigned not null auto_increment primary key,client_idvarchar (40) not null,redirect_urivarchar(255) not null,created_attimestamp null,updated_at` timestamp null)
    default character set utf8mb4 collate utf8mb4_unicode_ci)

    [PDOException]
    SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'oauth_client_endpoints' already exists`

    I have on my Homestead box "MariaDB version 10" (i added mariadb=true on the Homestead.yaml file).

    I joined some snapshot, i think it will help. capture d ecran 2016-07-20 a 15 30 56 capture d ecran 2016-07-20 a 15 31 04

    Thanks

    opened by enimiste 4
  • Vue i18n cannot translate

    Vue i18n cannot translate

    I am getting the following error:

    [vue-i18n] Cannot translate the value of keypath "user.users". Use the value of keypath as default

    I do not know how to generate them, thanks

    opened by german-bortoli 3
  • "AccessDeniedHttpException" while seeding new model

    The UsersTableSeeder works well and also passes all the tests; however, when I created a new model "Post" according to the guide, it throws "[Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException] " while seeding. I have also checked on Tinker, it was there for Post model but not for the User model. Can you give me some pointers that how to resolve it?

    opened by reehan79 3
  • Why is `.idea` included?

    Why is `.idea` included?

    Quoting the readme:

    Note: You may notice that .idea folder is included. No worries, any conflict files in .idea folder has been ignored as in .gitignore file.

    My question is: Why is it included?

    Anyway, thank you for this package.

    Side note: hey, I just noticed it uses Laravel Log Viewer (author here). Thank you to use it!

    opened by rap2hpoutre 2
  • How to change timezone?

    How to change timezone?

    I want to change the timezone, I have changed the timezone in config/app.php to 'timezone' => 'PRC'. And when I check the database, I found the field I added myself showed the correct time, however the default field added by the Framework itself created _at, updated_at showed the UTC time.

    I want to know whether exits a place to change the framework timezone?

    Thx!

    opened by crazcdll 2
  • php artisan migrate

    php artisan migrate

    HI: when I run

    php artisan migrate

    I get the flowing error

    [Illuminate\Database\QueryException] SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: nodena me nor servname provided, or not known (SQL: select * from information_sche ma.tables where table_schema = someline_starter and table_name = migra tions)

    opened by yursile 1
  • 429 Too Many Requests

    429 Too Many Requests

    Client error: 'POST http://api.XXX.com.cn/oauth/token' resulted in a '429 Too Many Requests' response: Too Many Attempts.

    Hello, when I send some requests a little fast, I would got the error above.

    I have try do modify the throttle config in routes/web.php and routes/api.php, but nothing changed.

    THX!

    opened by crazcdll 6
  • Method Someline\Repository\Generators\Commands\EntityCommand::handle() does not exist

    Method Someline\Repository\Generators\Commands\EntityCommand::handle() does not exist

    C:\laragon\www\someline-starter>php artisan starter:entity Post

    [ReflectionException] Method Someline\Repository\Generators\Commands\EntityCommand::handle() does not exist

    opened by WalonDreamer 0
Releases(v0.8.2)
A starter template from which to build Laravel + Vite apps

Stack The Laravel framework is fast, clean, and filled with best practices. In this stack, it will handle the backend as an API. The Laravel Vite pack

null 7 Nov 14, 2022
Here you have yet another framework for writing RESTful web services in PHP

PHP-Rocker Here you have yet another framework for writing RESTful web services in PHP, jay! What sets this framework apart from many of the others is

Victor Jonsson 43 May 19, 2022
a simple and secured RESTful API made with codeIgniter and JSON Web Tokens

CodeIgniter 4 Application Starter What is CodeIgniter? CodeIgniter is a PHP full-stack web framework that is light, fast, flexible and secure. More in

null 2 Oct 8, 2021
Quick Start - Project With Laravel 8.x and AdminLTE 3

Quick Start - Project With Laravel 8.x and AdminLTE 3 (feat. Docker) Cursos de Laravel - PT-BR Step by step Clone this Repository git clone https://gi

EspecializaTi 3 May 24, 2022
Quick new application creation with Laravel and Valet

Super-powered laravel new for Laravel and Valet Lambo is a command-line tool that replaces the Laravel installer and wraps up the most common tasks yo

Tighten 593 Dec 30, 2022
Laravel Quick-Start - a boilerplate for Laravel Application with typical packages preinstalled and configured

Laravel Quickstart is a boilerplate for Laravel Application with typical packages preinstalled and configured to extend a full-fledged application. We tried to make it as minimal as possible.

Vijay Goswami 18 Sep 8, 2022
Ikoncoder is a self starter milestone web designing and deveflopment software developer.

Ikoncoder auth create auth to manage users, roles and permissions in laravel framework project Installation Require the package using composer: compos

ikoncoder 1 Oct 26, 2021
PHP Framework for building scalable API's on top of Laravel.

Apiato Build scalable API's faster | With PHP 7.2.5 and Laravel 7.0 Apiato is a framework for building scalable and testable API-Centric Applications

Apiato 2.8k Dec 29, 2022
PHP Framework for building scalable API's on top of Laravel.

Apiato Build scalable API's faster | With PHP 7.2.5 and Laravel 7.0 Apiato is a framework for building scalable and testable API-Centric Applications

Apiato 2.8k Dec 31, 2022
👔 Enterprise Web application starter kit or template using Laravel

Laravel Enterprise Starter Kit (LESK) Description LESK, is a template project based on the Laravel LTS, combining a set of features that can kick star

Sebastien Routier 1 Dec 31, 2020
Laravel Framework 5 Bootstrap 3 Starter Site is a basic application with news, photo and video galeries.

Laravel Framework 5.1 Bootstrap 3 Starter Site Starter Site based on on Laravel 5.1 and Boostrap 3 Features Requirements How to install Application St

null 900 Dec 22, 2022
Simplified Repository pattern implementation in Laravel

Laravository - Repository Pattern for Laravel Simplified Repository pattern implementation in Laravel. Requirement Laravel 8.x Installation Execute th

Benny Rahmat 14 Oct 1, 2021
This package provides an artisan command to generate a basic crud with Restful API support

NHRROB Crud Generator Package This package provides an artisan command to generate a basic crud composer install command: composer require nhrrob/crud

Nazmul Hasan Robin 22 Jun 24, 2022
Dynamic Framework :: A PHP starter kit for Noobs

A PHP starter kit for Noobs Author : Abdulbasit Rubeiyya The dynamic framework is not exactly a framework, but more of a starter kit for you, the thin

Abdulbasit Rubeiyya 1 Dec 16, 2022
Lumen PHP Framework (Starter Template)

This repository contains JWT Auth, Form Request, Route List, Redis, RabbitMQ and Mail packages. A ready auth system comes with the project

Yasin Köse 1 Feb 11, 2022
A simple starter kit for using TypedCMS with the Laravel framework.

TypedCMS Starter Kit for Laravel Our stater kits are tailored solutions for each platform, unlike the simple API wrappers offered by other vendors. Th

TypedCMS 1 Nov 20, 2021
Prepare your Laravel apps incredibly fast, with various commands, services, facades and boilerplates.

Grafite Builder Grafite has archived this project and no longer supports or develops the code. We recommend using only as a source of ideas for your o

Grafite Inc 997 Dec 22, 2022
Super2Do Apps menggunakan Laravel + Vue JS

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Alfian Luthfi 1 Feb 7, 2022
Generate Admin Panels CRUDs and APIs in Minutes with tons of other features and customizations with 3 different themes

InfyOm Laravel Generator Generate Admin Panels CRUDs and APIs in Minutes with tons of other features and customizations with 3 different themes. Docum

InfyOmLabs (InfyOm Technologies) 3.5k Jan 1, 2023