The source code for the Laravel Tricks website

Overview

Laravel-Tricks

Laravel-Tricks is now under the ownership of Tighten, and all development is taking place under a private repo until we can extract some of its code and make it public.

This is an archive of an old public version of the codebase the previous owners created and kept in sync with their private version.


Laravel Tricks is a website created by Stidges and Maksim Surguy as an unofficial repository of tips and tricks for web developers using the Laravel PHP framework.

To see what this is about check out http://www.laravel-tricks.com!

Table of contents

Purpose and Features

The purpose of this repository is to provide a source of a real website that's using the Laravel PHP Framework and implements good design patterns for its architecture.

The features of Laravel-Tricks are:

  • Multi User platform that enables registered users to post short excerpts of code and descriptions to go along with the code.
  • Sorting and search.
  • Categories and tags for each user submitted entry.
  • OAuth 2 Github Registration and Login using OAuth 2 client from PHP League.
  • Disqus integration for commenting.
  • Customized Bootstrap theme.
  • AJAX favoriting.
  • Gravatar integration.
  • Using jQuery FileAPI for avatar uploads and cropping.
  • Using Intervention Image to handle the server side of the avatar uploads.
  • Pinterest-inspired grid implemented with Masonry.
  • Presenter classes implemented with the Laravel Auto Presenter package.

Requirements

The Laravel-Tricks website requires a server with PHP 5.4+ that has the MCrypt extension installed.

The database engine that is used to store data for this application could be any of the engines supported by Laravel such as:

  • MySQL
  • Postgres
  • SQLite and
  • SQL Serve.

Quick Start and Installation

To get started and start making something of your own using this repository as a base: download this repository, create an empty database that this application will use, configure a few settings in the app/config folder and enjoy!

Configuration

  • Open up app/config/database.php and configure connection settings for your database.

  • Configure hostname in bootstrap/start.php file to match your machine's hostname:

    $env = $app->detectEnvironment(array(
    
        'local' => array('your-machine-name'), // Edit this line
    
    ));
    
  • If you want to use Github OAuth for login and registration, make sure to create a Github application first and provide its client ID and client secret to the config in app/config/social.php. Also make sure you're using http:// /login/github for Authorization callback URL

After this simple configuration you can populate the database by running a couple commands shown below.

Installation

CD into the directory of this project and run the following three commands:

  1. composer install
  2. php artisan migrate
  3. php artisan db:seed

This will install all Composer dependencies, create the database structure and populate the database with some sample data so that you could see this project in action.

Documentation

While the code of the application is heavily documented it helps to know how the code is structured and what standards it follows.

Project structure

To start, we have removed the app/models directory and created a custom namespace for the site. This namespace houses all of the application's domain classes.

After that, we have namespaced the app/Controller directory, so that whenever new controllers are created composer dump-autoload doesn't have to be called every time.

The domain classes can be found in the app/Tricks directory. This contains all the application's logic. The controllers merely call these classes to perform the application's tasks.

The app/Tricks directory is structured in the following manner:

  • Exceptions: Contains all the exceptions that are thrown from within the domain classes. All the exceptions (except for the GithubEmailNotVerifiedException) extend the Tricks\AbstractNotFoundException class. This makes it much easier to handle 404 errors. (The handling can be found in the app/start/global.php file).
  • Facades: Contains all the custom Facade classes that are used throughout the application.
  • Presenters: Contains all the Presenter classes which utilizes the Laravel Auto Presenter package. This provides a clean way to keep logic out of your views and encapsulate it all into one place.
  • Providers: Contains all the application's Service Provider classes, which register the custom components to the application's IoC container. This, among many other advantages, eases the process of injecting classes/implementations and allows the creation of Facades.
  • Repositories: Contains all the Repository classes. Repositories are used to abstract away the persistance layer interactions. This causes your classes to be less tightly coupled to an ORM like Eloquent. All the repositories implement an interface found in the root of the Repositories directory, which makes it easier to switch implementations.
  • Services: This directory is split into multiple sub-directories:
    • Forms: Contains the Form classes, which are used to validate the user input upon form submission.
    • Navigation: Contains the navigation Builder class, which is used to build the site's navigation from a configuration file. The configuration file can be found under app/config/navigation.php.
    • Social: Contains the social integration classes for Github and Disqus. The Github class is used for the Github login and registration process. The Disqus class is used to get the comment count for the tricks.
    • Upload: Contains the ImageUploadService class. This class handles the uploading and resizing of an avatar.

Standards

The Laravel-Tricks application is PSR-2 compliant (and PSR-0 and PSR-1, which PSR-2 extends). PSR-2 is a coding standard by PHP-FIG which aims to unify the way PHP code gets written, so that everyone collaborating on a project will adhere to the same standards. This makes the code easier to read and understand.

Contributing

Contributions to this repository are more than welcome although not all suggestions will be accepted and merged with the live site.

Community

Keep track of development and Laravel-Tricks news.

Authors

Stidges

Maksim Surguy

Copyright and license

Code released under the MIT license.

Comments
  • Whoops, looks like something went wrong.

    Whoops, looks like something went wrong.

    The installation was successful. When you open the site - this error: Whoops, looks like something went wrong.

    Predis\Connection\ConnectionException …/­vendor/­predis/­predis/­lib/­Predis/­Connection/­AbstractConnection.php141

    Predis \ Connection \ ConnectionException Connection refused [tcp://127.0.0.1:6379]

    • Helper method to handle connection errors. *
      • @param string $message Error message.
      • @param int $code Error code. */ protected function onConnectionError($message, $code = null) { CommunicationException::handle(new ConnectionException($this, "$message [{$this->parameters->scheme}://{$this->getIdentifier()}]", $code)); }
    opened by yuri25 12
  • bad asset file names

    bad asset file names

    I was always thinking I'm doing something wrong but now that I'm working on it again and still don't understand it, I really wonder what I'm missing.

    There a file called [email protected] in this directory. https://github.com/CodepadME/laravel-tricks/tree/master/public/img. However, when I look at the code https://github.com/CodepadME/laravel-tricks/blob/master/app/views/partials/navigation.blade.php#L12 I only see a reference to [email protected].

    I renamed a bunch of files when I first deployed it to my site, but I'd like to be able to pull changes from the official repository which isn't possible anymore due to a number of differences.

    opened by Remo 6
  • Comments count 0 in Card View

    Comments count 0 in Card View

    Could you please share the code regarding getting the count from disqus for each trick in card view. Currently it is hardcoded as 0.

    Thanks in advance

    opened by canaveensetia 5
  • Having problems installing on windows

    Having problems installing on windows

    Hi,

    I've been trying to install this using wamp and haven't been having any luck. I'm redirected to site unavailable. Any help would be greatly appreciated!

    opened by amirshawn 5
  • strings moved to

    strings moved to "lang"

    As mentioned here https://github.com/CodepadME/laravel-tricks/issues/11, it would be great to have all strings in one place.

    This pull request is incomplete, but before I spend more time on this, would you guys merge something like this? Anything I'd have to change? (I'm just trying to make sure I can update my concrete5recipes sites)

    opened by Remo 4
  • User types

    User types

    Hi,

    I saw in config such option:

    // available user permission types that are matched by user_type column in the users table
    'user_types' => array(
        'admin'     => 100,
        'reviewer'  => 20,
        'user'      => 10
    ),
    

    but no management for this, are there any plans for implementing this?

    opened by cojocaru 4
  • Feature: Add Next and Previous post navigation to Post View page

    Feature: Add Next and Previous post navigation to Post View page

    I'd like to see a next and previous post link on the post view page so I can easily click through to the next. I generally come back to the site once every couple weeks and "catch up". Going back each time sucks.

    opened by chadwithuhc 4
  • Fix the search bug

    Fix the search bug

    If I search the tricks by test term, the following SQL is executed.

    select count(*) as aggregate from `tricks` where `title` LIKE '%test%' or `description` LIKE '%test%' or
     (select count(*) from `tags` inner join `tag_trick` on `tags`.`id` = `tag_trick`.`tag_id` 
      where `tag_trick`.`trick_id` = `tricks`.`id` and `name` LIKE '%test%' or `slug` LIKE '%test%') >= 1 or 
     (select count(*) from `categories` inner join `category_trick` on `categories`.`id` = `category_trick`.`category_id` 
      where `category_trick`.`trick_id` = `tricks`.`id` and `name` LIKE '%test%' or `slug` LIKE '%test%') >= 1
    

    Two parts of that SQL causes irrelevant result to the search term.

    and `name` LIKE '%test%' or `slug` LIKE '%test%'
    .
    .
    .
    and `name` LIKE '%test%' or `slug` LIKE '%test%
    

    I think that title only would be sufficient for search and in order to fix the above bug, I modified the code.

    opened by yhbyun 3
  • Installation problems using

    Installation problems using "laravel/framework": "4.1.*"

    I'm trying to install the app project files using composer and it seems that for some reason Laravel version 4.1 is no longer accessible from the composer installation. Its possible to confirm this? Or maybe I'm doing something wrong. In the mean time, I change composer's Laravel requirement to 4.2 and the installation runs smoothly.

    opened by jamesxv7 3
  • New Form Fields and Database Table Columns

    New Form Fields and Database Table Columns

    Hello Guys,

    I created new form fields in the settings area (settings.blade.php).

    I also added the new data to the UsersTableSeeder.php like so: [ 'username' => 'kwame', 'email' => '[email protected]', 'password' => Hash::make('password'), 'city' => 'London', 'country' => 'UK', 'descriptiom' => 'I am a PHP developer based in London', 'is_admin' => '1' ]

    What else do I have to do to make this work properly (and create columns) so that I can seed the new data into it?

    What am I missing? I hope someone can help me solve this.

    opened by kwameboame 3
  • Fatal Error Exception after install

    Fatal Error Exception after install

    followed the instructions to install locally on windows and the following exception is provided:- ... Symfony \ Component \ Debug \ Exception \ FatalErrorException Class Tricks\User contains 3 abstract methods and must therefore be declared abstract or implement the remaining methods (Illuminate\Auth\UserInterface::getRememberToken, Illuminate\Auth\UserInterface::setRememberToken, Illuminate\Auth\UserInterface::getRememberTokenName) ...

    opened by bobbypiper 3
  • [Purpose] Better home perform and save resources

    [Purpose] Better home perform and save resources

    Its wise we usage cache on home render?

    My suggestion is save home rendered on file or memory cache (depends of host), and update this cache on Model events.

    This way, we can show, for example, more items for first page.

    screen shot 2019-01-21 at 10 11 59

    opened by sr2ds 0
  • Valet Installation problem

    Valet Installation problem

    I am installing this into a valet 7.1 and after doing all the configuration I get this error.

    Symfony \ Component \ Debug \ Exception \ FatalErrorException Uncaught TypeError: Argument 1 passed to Illuminate\Exception\WhoopsDisplayer::display() must be an instance of Exception, instance of Error given, called in /Volumes/Others/valet/tricks/vendor/laravel/framework/src/Illuminate/Exception/Handler.php on line 279 and defined in /Volumes/Others/valet/tricks/vendor/laravel/framework/src/Illuminate/Exception/WhoopsDisplayer.php:43 Stack trace: #0 /Volumes/Others/valet/tricks/vendor/laravel/framework/src/Illuminate/Exception/Handler.php(279): Illuminate\Exception\WhoopsDisplayer->display(Object(Error)) #1 /Volumes/Others/valet/tricks/vendor/laravel/framework/src/Illuminate/Exception/Handler.php(158): Illuminate\Exception\Handler->displayException(Object(Error)) #2 /Volumes/Others/valet/tricks/vendor/laravel/framework/src/Illuminate/Exception/Handler.php(169): Illuminate\Exception\Handler->handleException(Object(Error)) #3 [internal function]: Illuminate\Exception\Handler->handleUncaughtException(Object(Error)) #4 {main} thrown open: /Volumes/Others/valet/tricks/vendor/laravel/framework/src/Illuminate/Exception/WhoopsDisplayer.php

    /**
     * Display the given exception to the user.
     *
     * @param  \Exception  $exception
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function display(Exception $exception)
    {
    	$status = $exception instanceof HttpExceptionInterface ? $exception->getStatusCode() : 500;
    

    Tried all auto-dump , but dont know what is the problems are. Please help me.

    opened by alpanango 0
  • production.ERROR

    production.ERROR

    Illuminate\Database\QueryException

    SQLSTATE[HY000]:

    General error: 1005 Can't create table 'laravel_blog.#sql-513e_1e3' (errno: 121)

    (SQL: alter table poet_tricks add constraint tricks_user_id_foreign foreign key (user_id) references poet_users (id) on delete cascade on update cascade) in /www/laravel-tricks/vendor/laravel/framework/src/Illuminate/Database/Connection.php:555

    opened by baiyutang 0
  • how to set separate meta description for category and tags pages

    how to set separate meta description for category and tags pages

    currently laravel-tricks project is sharing the same meta description on index ,category ,and tags browsing pages

    eg : http://laravel-tricks.com/categories/requests-and-input http://laravel-tricks.com/tags/database and http://laravel-tricks.com shared showing the same meta description

    i wants to change the description for all category, tags browsing page for each category and tag there should be different meta description..

    opened by sahil1572 0
  • Better code formatting

    Better code formatting

    Would be better if the code in PRE blocks had overflow-x set to scroll (wrapping is fugly and hard to read)

    Also, if we use tabs in the gist, please respect that in the PRE! Otherwise it get a bit lumpy.

    Ideally you'd ask for each gist or have an option in settings to set the number of spaces.

    As a start though (and I know this is debatable) for HTML/PHP 4 spaces per tab is probably the most common.

    Many thanks!

    opened by davestewart 0
Releases(1.4.0)
  • 1.4.0(Sep 25, 2015)

    Integrates latest PRs and is what's on production currently.

    Specifically the release is using language strings instead of hard coded text, allowing you to translate the whole application quickly.

    Source code(tar.gz)
    Source code(zip)
  • 1.3.0(Apr 17, 2014)

    This update is essential for tightened security of the "remember me" functionality. Per Laravel 4.1.26 release tightening application security, the users table require a remember me column and methods to set the remember me hash in the DB instead of in the cookie.

    Read more at http://laravel.com/docs/upgrade#upgrade-4.1.26

    Source code(tar.gz)
    Source code(zip)
  • 1.2.1(Feb 27, 2014)

  • 1.2.0(Feb 27, 2014)

    This release adds the following improvements:

    Extract view trick throttle to seperate filter class The view trick throttle filter is responsible for incrementing the trick view count. It does this by adding a delay to the trick view, so that revisiting a trick shortly after viewing it doesn't increment the view counter again.

    Extract increment view count event to seperate event class This class handles the actual incrementing of the trick view count.

    Add 'Previous Trick' and 'Next Trick' buttons to the single trick view This allows for navigation to the next and previous tricks, so that you can easily walk through them without returning to the browse page. Thanks to @chadwithuhc for the suggestion!

    Various bug fixes and improvements

    Source code(tar.gz)
    Source code(zip)
  • 1.1.0(Feb 21, 2014)

    The SitemapController and FeedsController have been cleaned up. The generation of the feeds and sitemaps has been extracted to dedicated classes.

    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Feb 20, 2014)

Owner
CodepadME
Open source projects by @msurguy and @stidges
CodepadME
The source code to Charlie’s old website.

About This is the source code to my website built with the Laravel framework. Set-up Simply clone this repository, install composer and node dependenc

Charlie Joseph 6 Dec 29, 2021
LaravelSnippets.com website | A repository of useful code snippets for Laravel PHP framework

LaravelSnippets.com website | A repository of useful code snippets for Laravel PHP framework. Submit, grab and share!

John Kenn 331 Nov 22, 2022
Source code of Strm.pl, brand-new social service.

Strimoid Source code of Strm.pl, brand-new social service.

Strimoid 67 Oct 20, 2022
Infopanel is a simple tool getting some information from source. It works basically like a slider that shows only title, image, a little bit description and QR-Code for links.

Infopanel is a simple tool getting some information from source. It works basically like a slider that shows only title, image, a little bit description and QR-Code for links. It has its own GUI for the editing. The GUI provides a very simple role concept. This tool can be used for digital signage, Information panels, News or Events or similar.

null 4 Aug 22, 2022
This repository contains source code of my personal portfolio at naurislinde.com

The source code of naurislinde.com This repository contains source code of my personal portfolio at naurislinde.com Getting Started These instructions

Nauris Linde 7 Sep 12, 2022
Project Website Social Network Laravel, Vue3

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

Old Wolf 1 Nov 4, 2021
Laravel website prototype with backoffice for content and users management

LaraProto LaraProto is a Laravel website prototype with backoffice for content and users management. Just install and glue your front end views Based

Marco Afonso 7 Aug 26, 2016
A simple News/Bloging Website Build Using Vue and Inertia with Laravel

Laravel Vue and Inertia News Site This is a simple News/Bloging Website Build Using Vue and Inertia with Laravel.

Tauseed 5 Sep 21, 2022
A powerful open source Laravel Blog with WYSWYG and CRUD (Create Read Update Delete) built on Laravel 5.8 and Bootstrap 4

Larablog A powerful open source Laravel Blog with WYSWYG and CRUD (Create Read Update Delete) built on Laravel 5.8 and Bootstrap 4 Table of contents F

Jeremy Kenedy 144 Oct 11, 2022
NamelessMC is a free, easy to use & powerful website software for your Minecraft server

NamelessMC - v2 pre-release 10 NamelessMC is a free, easy to use & powerful website software for your Minecraft server, which includes a large range o

NamelessMC 520 Jan 1, 2023
Website peminjaman ruang

Pinjam Ruang Pinjam Ruang Mudah dan Cepat! Lihat Demo · Laporkan Kesalahan · Ajukan Fitur Baru Daftar Isi Tentang Pinjam Ruang Dibuat Menggunakan Demo

VREEdom 22 Dec 22, 2022
Codsletter: turn your website into a periodical newsletter, all automatically!

About Codsletter With Codsletter, you can turn your blog into a periodical newsletter with few clicks and some configuration. In particular, you can:

Mario Linguito 11 Nov 24, 2022
A simple, not so bad looking Minecraft Server's website template

Minecraft Server 官网模板 本仓库为 Minecraft 服务器官网模板,主要通过 Bootstrap 和 Argon 组件库实现 本项目基于 https://github.com/nyancatda/mcserverweb 二开 config.json参数说明 参数 说明 备注 s

GBCLStudio 邱晨晟曦 2 Mar 4, 2022
Pengembangan website OSIS SMAN 17 Kabupaten Tangerang, dimulai dari tanggal 14 februari 2021

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

enggar abin 0 Dec 25, 2021
website that contains solutions to make IT support easier to solve problems.

Project This website is manual guide when you face a problem and don't want to call IT support. hr always call for helping with repeated problem. I fe

Tanutchakorn Khaisang 1 Dec 22, 2021
The simplest, most intuitive way to host your photos on your website.

Gallery 3.1+ (development version) About Gallery 3 is a web based software product that lets you manage your photos on your own website. You must have

Brad Dutton 103 Dec 22, 2022
PHP SİMPLE HTML DOM with news website

PHP SİMPLE HTML DOM with news website I found a library that can pull data from a site to my own site with php. I used it and pulled the yield from a

Uğur Mercan 2 Oct 26, 2022
SISTEM PEMINJAMAN BUKU adalah sebuah sistem aplikasi berbasis website untuk transaksi peminjaman buku

SISTEM PEMINJAMAN BUKU adalah sebuah sistem aplikasi berbasis website untuk transaksi peminjaman buku Fitur utama SISTEM PEMINJAMAN Login Management b

reza aditya eka wardana 8 Sep 7, 2022
The objective of this project is to manage The Website Manga, this site permits to Client to show, read and download Manga with the possibility to react, vote, and save his data.

The objective of this project is to manage The Website Manga, this site permits to Client to show, read and download Manga with the possibility to react, vote, and save his data.

Reda Ennakouri 5 Nov 23, 2022