Questions tagged [laravel]

The Laravel framework is an open-sourced PHP web framework that allows developers to create dynamic and scalable web applications. The source code of Laravel is hosted on GitHub and released under the MIT license.

Laravel is an open-sourced MVC framework for PHP web development released under the MIT license. Laravel helps you create applications with expressive, elegant syntax. The current Laravel version is 10.x. For all Laravel releases, bug fixes are provided for 18 months, and security fixes are provided for two years. Major framework releases are released yearly, while minor and patch releases may be released weekly.

Feature Overview

  • Model–View–Controller (MVC) framework
  • Simple routing using Closures or Controllers
  • Views and templating
  • Built-in Blade templating engine
  • Driver-based session and cache handling
  • URL Routing Configuration
  • Database abstraction with query builder
  • Eloquent ORM
  • Error Handling
  • Redis framework integration and API
  • Reverse Routing
  • Inversion of control (IoC) container
  • Middleware
  • Authentication
  • Authorization
  • Database Migrations
  • PHPUnit Integration
  • Automatic Pagination
  • Bundles
  • Queue system
  • Events and Filters
  • Task Scheduling
  • Accessors and Mutators
  • Markdown Mailable
  • Monolog Logging Library
  • Notifications

Documentation

API Documentation

Packages

Useful Services

Other notable tags

Community

Podcast

Resources and Tutorials

Books

Laravel 4

Laravel was created, and development is led by Taylor Otwell


Official Logo:

enter image description here

208084 questions
375
votes
25 answers

Could not open input file: artisan

When trying to create a new laravel project, The following error appears on the CLI: Could not open input file: artisan Script php artisan clear-compiled handling the post-install-cmd event returned with an error I am using the latest version of…
wessodesigner
  • 4,485
  • 3
  • 16
  • 9
375
votes
17 answers

Laravel - Eloquent or Fluent random row

How can I select a random row using Eloquent or Fluent in Laravel framework? I know that by using SQL, you can do order by RAND(). However, I would like to get the random row without doing a count on the number of records prior to the initial…
DigitalWM
  • 4,406
  • 3
  • 18
  • 15
372
votes
2 answers

Laravel - Eloquent "Has", "With", "WhereHas" - What do they mean?

I've found the concept and meaning behind these methods to be a little confusing, is it possible for somebody to explain to me what the difference between has and with is, in the context of an example (if possible)?
user4898812
358
votes
9 answers

How to use multiple databases in Laravel

I want to combine multiple databases in my system. Most of the time the database is MySQL; but it may differ in future i.e. Admin can generate such a reports which is use source of heterogeneous database system. So my question is does Laravel…
Chintan7027
  • 7,115
  • 8
  • 36
  • 50
351
votes
13 answers

Eloquent Collection: Counting and Detect Empty

This may be a trivial question but I am wondering if Laravel recommends a certain way to check whether an Eloquent collection returned from $result = Model::where(...)->get() is empty, as well as counting the number of elements. We are currently…
bitinn
  • 9,188
  • 10
  • 38
  • 64
350
votes
6 answers

How to query all the GraphQL type fields without writing a long query?

Assume you have a GraphQL type and it includes many fields. How to query all the fields without writing down a long query that includes the names of all the fields? For example, If I have these fields : public function fields() { return…
BlackSigma
  • 3,505
  • 2
  • 15
  • 8
343
votes
30 answers

How to Get the Current URL Inside @if Statement (Blade) in Laravel 4?

I am using Laravel 4. I would like to access the current URL inside an @if condition in a view using the Laravel's Blade templating engine but I don't know how to do it. I know that it can be done using something like
user2443854
  • 3,439
  • 2
  • 13
  • 3
339
votes
11 answers

Proper Repository Pattern Design in PHP?

Preface: I'm attempting to use the repository pattern in an MVC architecture with relational databases. I've recently started learning TDD in PHP, and I'm realizing that my database is coupled much too closely with the rest of my application. I've…
Jonathan
  • 18,229
  • 10
  • 57
  • 56
338
votes
29 answers

How to fix Error: laravel.log could not be opened?

I'm pretty new at laravel, in fact and I'm trying to create my very first project. for some reason I keep getting this error (I haven't even started coding yet) Error in exception handler: The stream or file…
frankelot
  • 13,666
  • 16
  • 54
  • 89
338
votes
31 answers

How to Set Variables in a Laravel Blade Template

I'm reading the Laravel Blade documentation and I can't figure out how to assign variables inside a template for use later. I can't do {{ $old_section = "whatever" }} because that will echo "whatever" and I don't want that. I understand that I can…
duality_
  • 17,738
  • 23
  • 77
  • 95
333
votes
20 answers

Get Specific Columns Using “With()” Function in Laravel Eloquent

I have two tables, User and Post. One User can have many posts and one post belongs to only one user. In my User model I have a hasMany relation... public function post(){ return $this->hasmany('post'); } And in my post model I have a…
Awais Qarni
  • 17,492
  • 24
  • 75
  • 137
324
votes
4 answers

PHP7 : install ext-dom issue

I'm running laravel 5.4 on Ubuntu 16.04 server with PHP7. trying to install cviebrock/eloquent-sluggable package throw some error: pish@let:/home/sherk/ftp/www$ sudo composer require cviebrock/eloquent-sluggable Do not run Composer as root/super…
alex
  • 7,551
  • 13
  • 48
  • 80
324
votes
15 answers

Laravel 5 - artisan seed [ReflectionException] Class SongsTableSeeder does not exist

When I run php artisan db:seed I am getting the following error: [ReflectionException] Class SongsTableSeeder does not exist What is going on? My DatabaseSeeder class:
Sasha
  • 8,521
  • 23
  • 91
  • 174
323
votes
39 answers

Laravel Migration Error: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

Migration error on Laravel 5.4 with php artisan make:auth [Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1071…
abSiddique
  • 11,647
  • 3
  • 23
  • 30
321
votes
31 answers

Facebook OAuth "The domain of this URL isn't included in the app's domain"

Let me first start with saying I've searched for an answer to this question for quite some time... I'm trying to setup Facebook OAuth to work with my application that is being developed locally on my machine. Everything was working perfect with…
dangel
  • 7,238
  • 7
  • 48
  • 74