Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

💻:octocat: A hackathon/MVP boilerplate for laravel web applications. Start your hackathons without hassle.

License

NotificationsYou must be signed in to change notification settings

unicodeveloper/laravel-hackathon-starter

Repository files navigation

Laravel Hackathon Starter - SUSUMU 進

Build StatusQuality Score

If you have attended any hackathons in the past, then you know how much time it takes to get a project started: decide on what to build, pick a programming language, pick a web framework, pick a CSS framework. A while later, you might have an initial project up on GitHub and only then can other team members start contributing. Or how about doing something as simple asSign in with Facebook authentication? You can spend hours on it if you are not familiar with how OAuth 2.0 works.

Even if you are not using this for a hackathon, Laravel Hackathon Starter is sure to save any developer hours or even days of development time and can serve as a learning guide for web developers.

Laravel is a web application framework with expressive, elegant syntax. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as authentication, routing, sessions, queueing, and caching.

Laravel Hackathon Starter is a boilerplate application developed with Laravel 5.2 to keep you ahead in hackathons.

Modern Theme

API Examples

Table of Contents

Features

  • Local Authentication using Email and Password
  • OAuth 1.0a Authentication via Twitter
  • OAuth 2.0 Authentication via Facebook, Google, GitHub, LinkedIn, Instagram
  • Flash notifications
  • MVC Project Structure
  • Bootstrap 3
  • Contact Form (powered by Mailgun, Sendgrid or Mandrill)
  • Account Management
  • Gravatar
  • Profile Details
  • Change Password
  • Forgot Password
  • Reset Password
  • Delete Account
  • CSRF protection
  • API Examples: Facebook, Foursquare, Last.fm, Tumblr, Twitter, Stripe, LinkedIn and more.
  • Automatic Documentation

Prerequisites

  • Mysql orPostgresql
  • PHP 5.4+
  • Command Line Tools
  •  Mac OS X:Xcode (orOS X 10.9+:xcode-select --install)
  •  Windows:Visual Studio
  •  Ubuntu / Linux Mint:sudo apt-get install build-essential
  •  Fedora:sudo dnf groupinstall "Development Tools"
  •  OpenSUSE:sudo zypper install --type pattern devel_basis
  •  Optic:npm install -g @useoptic/cli (needed for automatic documentation)

Note: If you are new to Laravel, I recommend to watchLaravel From Scratch screencast by Jeffery Way that teaches Laravel 5 from scratch. Alternatively,here is another great tutorial for building a project management app for beginners/intermediate developers -How to build a project management app in Laravel 5.

Getting Started

Via Cloning The Repository:

# Get the projectgit clone https://github.com/unicodeveloper/laravel-hackathon-starter.git hackathon-starter-pack# Change directorycd hackathon-starter-pack# Copy .env.example to .envcp .env.example .env# Create a database (with mysql or postgresql)# And update .env file with database credentials# DB_CONNECTION=mysql# DB_HOST=127.0.0.1# DB_DATABASE=laravelhackathon# DB_USERNAME=root# DB_PASSWORD=root# Install Composer dependenciescomposer install# Generate application secure key (in .env file)php artisan key:generate# Generate application secure key (in .env file)php artisan key:generatephp artisan serve

Via The Installer:

First, download the Laravel Hackathon Starter Pack Installer using Composer:

composer global require "unicodeveloper/hackathon-installer"

Make sure to place the~/.composer/vendor/bin directory (or the equivalent directory for your OS) in your PATH so thelarathon executable can be located by your system.

Once installed, thelarathon new command will create a fresh Laravel Hackathon Starter Pack installation in the directory you specify. For instance,larathon new mvp will create a directory namedmvp containing a fresh Laravel Hackathon Starter Pack installation with all of it's dependencies already installed. This method of installation is much faster than installing via Composer:

larathon new mvp

Via Composer Create-Project

Alternatively, you may also install Laravel Hackathon Starter Pack by issuing the Composercreate-project command in your terminal:

composer create-project --prefer-dist unicodeveloper/laravel-hackathon-starter hotel

This starter pack includes the following APIs. You will need to obtain appropriate credentials like Client ID, zClient secret, API key, or Username & Password by going through each provider and generate new credentials.

  • Cloudder
  • Twitter
  • Twillo
  • Github
  • Slack
  • Socialite Providers
  • Socialite LinkedIn

Obtaining API Keys

  • VisitGoogle Cloud Console
  • Click on theCreate Project button
  • EnterProject Name, then click onCreate button
  • Then click onAPIs & auth in the sidebar and selectAPI tab
  • Click onGoogle+ API underSocial APIs, then clickEnable API
  • Next, underAPIs & auth in the sidebar click onCredentials tab
  • Click onCreate new Client ID button
  • SelectWeb Application and click onConfigure Consent Screen
  • Fill out the required fields then click onSave
  • In theCreate Client ID modal dialog:
  • Application Type: Web Application
  • Authorized Javascript origins:http://localhost:3000
  • Authorized redirect URI:http://localhost:3000/auth/google/callback
  • Click onCreate Client ID button
  • Copy and pasteClient ID andClient secret keys into.env

Note: When you ready to deploy to production don't forget toadd your new url toAuthorized Javascript origins andAuthorized redirect URI,e.g.http://my-awesome-app.herokuapp.com andhttp://my-awesome-app.herokuapp.com/auth/google/callback respectively.The same goes for other providers.


  • VisitFacebook Developers
  • ClickMy Apps, then select *Add a New App from the dropdown menu
  • SelectWebsite platform and enter a new name for your app
  • Click on theCreate New Facebook App ID button
  • Choose aCategory that best describes your app
  • Click onCreate App ID button
  • In the upper right corner click onSkip Quick Star
  • Copy and pasteApp ID andApp Secret keys into.env
  • Note:App ID isclientID,App Secret isclientSecret
  • Click on theSettings tab in the left nav, then click on+ Add Platform
  • SelectWebsite
  • Enterhttp://localhost:3000 underSite URL

Note: After a successful sign in with Facebook, a user will be redirected back to home page with appended hash#_=_ in the URL. It isnot a bug. See thisStack Overflow discussion for ways to handle it.


  • Go toAccount Settings
  • SelectApplications from the sidebar
  • Then insideDeveloper applications click onRegister new application
  • EnterApplication Name andHomepage URL
  • ForAuthorization Callback URL:http://localhost:3000/auth/github/callback
  • ClickRegister application
  • Now copy and pasteClient ID andClient Secret keys into.env file

  • Sign in athttps://apps.twitter.com/
  • ClickCreate a new application
  • Enter your application name, website and description
  • ForCallback URL:http://127.0.0.1:3000/auth/twitter/callback
  • Go toSettings tab
  • UnderApplication Type selectRead and Write access
  • Check the boxAllow this application to be used to Sign in with Twitter
  • ClickUpdate this Twitter's applications settings
  • Copy and pasteConsumer Key andConsumer Secret keys into.env file

  • Sign in atLinkedIn Developer Network
  • From the account name dropdown menu selectAPI Keys
  • It may ask you to sign in once again
  • Click+ Add New Application button
  • Fill out all therequired fields
  • OAuth 2.0 Redirect URLs:http://localhost:3000/auth/linkedin/callback
  • JavaScript API Domains:http://localhost:3000
  • ForDefault Application Permissions make sure at least the following is checked:
  • r_basicprofile
  • Finish by clickingAdd Application button
  • Copy and pasteAPI Key andSecret Key keys into.env file
  • API Key is yourclientID
  • Secret Key is yourclientSecret

  • Sign up or log into yourdashboard
  • Click on your profile and click on Account Settings
  • Then click onAPI Keys
  • Copy theSecret Key. and add this into.env file

  • VisitPayPal Developer
  • Log in to your PayPal account
  • ClickApplications > Create App in the navigation bar
  • EnterApplication Name, then clickCreate app
  • Copy and pasteClient ID andSecret keys into.env file
  • App ID isclient_id,App Secret isclient_secret
  • Changehost to api.paypal.com if you want to test against production and use the live credentials





  • Go tohttp://www.mailgun.com
  • Sign up and add yourDomain Name
  • From the domain overview, copy and paste the default SMTPLogin andPassword into.env file

  • Go tohttp://mandrill.com
  • Sign up and add yourDomain Name
  • From the dashboard, click onGet SMTP credentials
  • Copy and paste the default SMTPLogin andPassword into.env file

  • Go tohttps://test.bitgo.com/
  • Sign up for an account.
  • Once logged into the dashboard, go to the top right selector and click 'account settings'
  • Under the developers tab, create your access token and copy and paste it into.env file

  • Go tohttps://www.twilio.com/try-twilio
  • Sign up for an account.
  • Once logged into the dashboard, expand the link 'show api credentials'
  • Copy your Account Sid and Auth Token

runphp artisan vendor:publish

Project Structure

NameDescription
config/app.phpConfiguration for service providers and facades
config/auth.phpConfiguration for password resets
config/broadcasting.phpConfiguration for broadcasting
config/cache.phpConfiguration for cache generation and storage
config/cloudder.phpConfiguration for cloudinary
config/compile.phpConfiguration for compilation
config/database.phpConfiguration for database drivers
config/filesystems.phpConfiguration for different file systems
config/github.phpConfiguration for github API
config/mail.phpConfiguration for mails
config/queue.phpConfiguration for queue
config/services.phpConfiguration for several services like mailgun etc.
config/session.phpConfiguration for sessions
config/ttwitter.phpTwitter API config file
config/twilio.phpTwilio API config file
config/view.phpConfiguration for location of views and view cache
controllers/AccountController.phpController for Account management
controllers/AviaryController.phpController for Aviary API functionality
controllers/ClockworkController.phpController for Clockwork API functionality
controllers/ContactController.phpController for Contact page
controllers/Controller.phpBaseController
controllers/GithubController.phpController for Github API functionality
controllers/LastFmController.phpController for LastFM API functionality
controllers/LobController.phpController for Lob API functionality.
controllers/NytController.phpController for New York Times API functionality
controllers/OauthController.phpController for Oauthentication
controllers/PaypalController.phpController for Paypal API functionality
controllers/SteamController.phpController for Stream API functionality
controllers/StripeController.phpController for Stripe API functionality
controllers/TwilioController.phpController for Twilio API functionality
controllers/TwitterController.phpController for Twitter API functionality
controllers/WebScrapingController.phpController for Web Scraping.
controllers/YahooController.phpController for Yahoo API functionality
controllers/user.jsController for user account management.
models/User.phpModel for User.
public/Static assets (fonts, css, js, img).
public/css/main.cssMain stylesheet for your app.
resources/views/account/Templates forlogin, password reset, signup, profile.
views/api/Templates for API Examples.
views/partials/alerts.blade.phpError, info and success flash notifications.
views/partials/navbar.blade.phpNavbar partial template.
views/layouts**/master.blade.phpBase template.
views/apidashboard.blade.phpAPI dashboard template.
views/contact.blade.phpContact page template.
views/welcome.blade.phpHome page template.
.travis.ymlTravis CI integration.
.env.exampleYour API keys, tokens, passwords and database URI.
composer.jsonFile for loading all php packages.
package.jsonFile for loading all necessary node modules.
artisanFile for enabling commands to run

List of Packages

PackageDescription
socialiteSign-in with Facebook, Twitter and Github
socialite providersSign-in with LinkedIn, Instagram
cloudderUpload images to Cloudinary
laravel githubGithub API library
clockworkClockwork SMS API library.
goutteScrape web pages using jQuery-style syntax.
laravel frameworkPHP web framework
twitterTwitter API library
twilioTwilio API library
lob-phpLob API library
lastfm-api-wrapperLastfm API library
phpunitPHP testing library
guzzlehttpSimplified HTTP Request library

Useful Tools and Resources

Recommended Design Resources

Recommended Laravel Libraries

Enabling Automatic Documentation

UsingOptic, you can use your API like normal, automatically documenting changes in behavior. To enable this, you'll first need to download Optic.

    npm install -g @useoptic/cli

Once you've installed Optic, you can start documenting your requests by runningapi start. Running this command will create a proxied version of your api, available atlocalhost:4000 - now, you can use the API like normal here, and Optic will automatically notice differences in the documented behavior, allowing you to automatically create documentation as your API changes.

To view the current documentation of the api, runapi spec at the root directory.

Useful Commands

    api start# use this to start monitoring your API    api spec# use this to inspect the current documentation of your API    api generate:oas# generates an OpenAPI specification for your currently documented API

For more information about Optic,check out the docs.

FAQ

Why do I getToken Mismatch Exception when submitting a form?

You need to add the following hidden input element to your form. This has beenadded in the existing codebase as part of the CSRF protection.

{!! csrf_field() !!}

I get a whoops error when I deploy my app, why?

Chances are you haven't generated the app key, so runphp artisan key:generate.Chances are you haven't put your credentials in your .env file.

How It Works (mini guides)

This section is intended for giving you a detailed explanation abouthow a particular functionality works. Maybe you are just curious abouthow it works, or maybe you are lost and confused while reading the code,I hope it provides some guidance to you.


How do flash messages work in this project?

Flash messages allow you to display a message at the end of the request and accessit on next request and only next request. For instance, on a failed login attempt, you woulddisplay an alert with some error message, but as soon as you refresh that page or visit a differentpage and come back to the login page, that error message will be gone. It is only displayed once.All flash messages are available in your views via laravel sessions.


How do I create a new page?

A more correct way to be to say "How do I create a new route". The main fileroutes.php contains all the routes.Each route has a callback function associated with it. Sometimes you will see 3 or more argumentsto routes. In cases like that, the first argument is still a URL string, while middle argumentsare what's called middleware. Think of middleware as a door. If this door prevents you fromcontinuing forward, you won't get to your callback function. One such example is a route that requires authentication.

Route::get('/account','UserController@getAccount');

It always goes from left to right. A user visits/account page. Thenauth middlewarechecks if you are authenticated:

 Route::get('/account', ['uses' =>'AccountController@getAccountPage','as'   =>'account.dashboard','middleware' => ['auth']]);

If you are authenticated, you let this visitor pass through your "door" by callingreturn $next($request); in the auth middleware and if you are authenticated, you will be redirected toAccount Management page, otherwise you will be redirected toLogin page.

Here is a typical workflow for adding new routes to your application. Let's say we are buildinga page that lists all books from database.

Step 1. Start by defining a route.

Route::get('/books','BookController@getBooks');

Step 2. Create a new modelBook.php inside theapp directory. You can simply runphp artisan make:model Book

namespaceApp;class Book{/**     * The attributes that are mass assignable.     *     * @var array     */protected$fillable = ['name','isbn',    ];}

Step 3. Create a migration file like so:php artisan make:migration create_books_table

useIlluminate\Database\Schema\Blueprint;useIlluminate\Database\Migrations\Migration;class CreateBooksTableextends Migration{/**     * Run the migrations.     *     * @return void     */publicfunctionup()    {        Schema::create('books',function (Blueprint$table) {$table->increments('id');$table->string('name');$table->string('isbn');$table->timestamps();        });    }/**     * Reverse the migrations.     *     * @return void     */publicfunctiondown()    {        Schema::drop('books');    }}

Step 4. Create a new controller file calledBookController inside theapp/Http/Controllers directory. You can simply runphp artisan make:controller BookController

namespaceApp\Http\Controllers;useIlluminate\Http\Request;useApp\Book;useApp\Http\Requests;useApp\Http\Controllers\Controller;class BookControllerextends Controller{/**     * Return all books     * @return mixed     */publicfunctiongetBooks()    {$books = Book::all();returnview('books')->withBooks($books);    }}

Step 5. Createbooks.blade.php template.

@extends('layouts.master')@section('content')    <div>        @include('layouts.partials.alerts')        <div>            <h2><i></i>All Books</h2>        </div>        <ul>        @foreach ($booksas$book)            <li> {{$book->name }} </li>        @endforeach        </div>    </div>@stop

That's it!


Laravel Eloquent Cheatsheet

Deployment

Once you are ready to deploy your app, you will need to create an account with a cloud platform to host it. These are not the only choices, but they are my toppicks. From my experience,Heroku is the easiest to get started with, deployments and custom domain support on free accounts.

1-Step Deployment with Heroku

  • Download and installHeroku Toolbelt
  • In terminal, runheroku login and enter your Heroku credentials
  • Fromyour app directory runheroku create
  • Create a Procfile in your app root. All this file needs to contain isweb: vendor/bin/heroku-php-nginx public orweb: vendor/bin/heroku-php-apache2 public if you prefer to use nginx.
  • Runheroku addons:add heroku-postgresql:dev to add a Postgres database to your heroku app from your terminal
  • Lastly, dogit push heroku master. Done!
  • Run artisan commands on heroku like soheroku run php artisan migrate

Note: To install Heroku add-ons your account must be verified.


  • Finally, you can now push your code to OpenShift by runninggit push -f openshift master
  • Note: The first time you run this command, you have to pass-f (force) flag because OpenShift creates a dummy server with the welcome page when you create a new Node.js app. Passing-f flag will override everything with yourHackathon Starter project repository.Do not rungit pull as it will create unnecessary merge conflicts.
  • And you are done!

  • Login toWindows Azure Management Portal
  • Click the+ NEW button on the bottom left of the portal
  • ClickCOMPUTE, thenWEB APP, thenQUICK CREATE
  • Enter a name forURL and select the datacenterREGION for your web site
  • Click onCREATE WEB APP button
  • Once the web site status changes toRunning, click on the name of the web site to access the Dashboard
  • At the bottom right of the Quickstart page, selectSet up a deployment from source control
  • SelectLocal Git repository from the list, and then click the arrow
  • To enable Git publishing, Azure will ask you to create a user name and password
  • Once the Git repository is ready, you will be presented with aGIT URL
  • Inside yourHackathon Starter directory, rungit remote add azure [Azure Git URL]
  • To push your changes simply rungit push azure master
  • Note:You will be prompted for the password you created earlier
  • OnDeployments tab of your Windows Azure Web App, you will see the deployment history

Note: Alternative directions, including how to setup the project with a DevOps pipeline are available athttp://ibm.biz/hackstart.A longer version of these instructions with screenshots is available athttp://ibm.biz/hackstart2.Also, be sure to check out theJump-start your hackathon efforts with DevOps Services and Bluemix video.

Contributing

Thank you for considering contributing to Laravel Hackathon Starter. The contribution guide can be found in theContribution File

Security Vulnerabilities

If you discover a security vulnerability within Laravel Hackathon Starter, please send an e-mail to Prosper Otemuyiwa atprosperotemuyiwa@gmail.com. All security vulnerabilities will be promptly addressed.

Credits

How can I thank you?

Why not star the github repo? I'd love the attention! Why not share the link for this repository on Twitter or HackerNews? Spread the word!

Don't forget tofollow me on twitter!

Thanks!Prosper Otemuyiwa.

License

The MIT License (MIT). Please seeLicense File for more information.

About

💻:octocat: A hackathon/MVP boilerplate for laravel web applications. Start your hackathons without hassle.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp