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 as Sign 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.
Optic:npm install -g @useoptic/cli (needed for automatic documentation)
Note: If you are new to Laravel, I recommend to watch
Laravel 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 project
git clone https://github.com/unicodeveloper/laravel-hackathon-starter.git hackathon-starter-pack
# Change directorycd hackathon-starter-pack
# Copy .env.example to .env
cp .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 dependencies
composer install
# Generate application secure key (in .env file)
php artisan key:generate
# Generate application secure key (in .env file)
php artisan key:generate
php 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 the larathon executable can be located by your system.
Once installed, the larathon 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 named mvp 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 Composer create-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.
Copy and paste Client ID and Client secret keys into .env
Note: When you ready to deploy to production don't forget to
add your new url to Authorized Javascript origins and Authorized redirect URI,
e.g. http://my-awesome-app.herokuapp.com and
http://my-awesome-app.herokuapp.com/auth/google/callback respectively.
The same goes for other providers.
Click My Apps, then select *Add a New App from the dropdown menu
Select Website platform and enter a new name for your app
Click on the Create New Facebook App ID button
Choose a Category that best describes your app
Click on Create App ID button
In the upper right corner click on Skip Quick Star
Copy and paste App ID and App Secret keys into .env
Note:App ID is clientID, App Secret is clientSecret
Click on the Settings tab in the left nav, then click on + Add Platform
Select Website
Enter http://localhost:3000 under Site 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 is not a bug. See this Stack Overflow discussion for ways to handle it.
laravel-quotes - For using all sorts of quotes especially DJKHALED in your app
Enabling Automatic Documentation
Using Optic, 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 running api start. Running this command will create a proxied version of your api, available at localhost: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, run api 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
Why do I get Token Mismatch Exception when submitting a form?
You need to add the following hidden input element to your form. This has been
added 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 run php 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 about
how a particular functionality works. Maybe you are just curious about
how 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 access
it on next request and only next request. For instance, on a failed login attempt, you would
display an alert with some error message, but as soon as you refresh that page or visit a different
page 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.
请发表评论