Laravel is a free, open-source PHP web application framework for the development of web applications following the model–view–controller (MVC) architectural pattern. Some of the features of Laravel are a modular packaging system with a dedicated dependency manager, different ways for accessing relational databases, utilities that aid in application deployment and maintenance, and its orientation toward syntactic sugar. Laravel is regarded as one of the most popular PHP frameworks.

Share tech news, updates, or what's on your mind.

Sign up to Post

Hi Experts

Could you point how to correctly configure PHP to use with Laravel?

After a composer update this error occurs
- laravel/framework v5.2.9 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.

To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php/7.2/cli/php.ini
    - /etc/php/7.2/cli/conf.d/10-mysqlnd.ini
    - /etc/php/7.2/cli/conf.d/10-opcache.ini
    - /etc/php/7.2/cli/conf.d/10-pdo.ini
    - /etc/php/7.2/cli/conf.d/20-calendar.ini
    - /etc/php/7.2/cli/conf.d/20-ctype.ini
    - /etc/php/7.2/cli/conf.d/20-exif.ini
    - /etc/php/7.2/cli/conf.d/20-fileinfo.ini
    - /etc/php/7.2/cli/conf.d/20-ftp.ini
    - /etc/php/7.2/cli/conf.d/20-gettext.ini
    - /etc/php/7.2/cli/conf.d/20-iconv.ini
    - /etc/php/7.2/cli/conf.d/20-json.ini
    - /etc/php/7.2/cli/conf.d/20-mysqli.ini
    - /etc/php/7.2/cli/conf.d/20-pdo_mysql.ini
    - /etc/php/7.2/cli/conf.d/20-pdo_sqlite.ini
    - /etc/php/7.2/cli/conf.d/20-phar.ini
    - /etc/php/7.2/cli/conf.d/20-posix.ini
    - /etc/php/7.2/cli/conf.d/20-readline.ini
    - /etc/php/7.2/cli/conf.d/20-shmop.ini
    - /etc/php/7.2/cli/conf.d/20-sockets.ini
    - /etc/php/7.2/cli/conf.d/20-sqlite3.ini
    - /etc/php/7.2/cli/conf.d/20-sysvmsg.ini
    - /etc/php/7.2/cli/conf.d/20-sysvsem.ini
    - /etc/php/7.2/cli/conf.d/20-sysvshm.ini
    - /etc/php/7.2/cli/conf.d/20-tokenizer.ini
  You can also run `php --ini` inside terminal to see which files are used by 

Open in new window

Cloud Class® Course: Ruby Fundamentals
LVL 12
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

I have XAMPP running on Windows 10. I am trying to setup a Virtual Host so that when I use "" as a domain I get directly to my public folder of laravel project.
Laravel is located at C:/xampp/htdocs/myapp/public.
By using http://localhost:8000/myapp/public/ i can access laravel index.php
So far i have tried the following:
http v-host.conf file
#this is the default address of XAMPP    
<VirtualHost *:8000>
   DocumentRoot "C:/XAMPP/htdocs/"
   ServerName localhost

<VirtualHost *:8000>
    DocumentRoot "C:/xampp/htdocs/myapp/public"
    ServerName myapp.test
    SetEnv NS_ENV variable_value

and in C:\Windows\System32\drivers\etc\host file localhost myapp.test

and after restarting apache and typing myapp.test leads to iis homepage instead of index.php in public folder.
I would like to find out whether is there a way to perform the following:

1) Include (when $id is not null) and exclude (when $id is null) in the where clause for the code below.
2) Switch between sortByDesc and sortBy based on condition ($sort=='asc' then.... $sort=='desc' then...) for the code below.

   $maxlimit = Product::where('category_id_fk',$id)->with(['child','price','variant','thumbnail','image','description'])->count();
   $products = Product::where('category_id_fk',$id)->with(['child','price','variant','thumbnail','image','description'])->take($recperpage)->get()->sortByDesc('price.list_price');
   $maxlimit = Product::with(['child','price','variant','thumbnail','image','description'])->count();
   $products = Product::with(['child','price','variant','thumbnail','image','description'])->take($recperpage)->get()->sortByDesc('price.list_price');

Open in new window

The objective is to simplify the code above as much as possible but achieve the same result.

Your help is kindly appreciated.
I am a college student. I have some money I inherited and I was thinking about starting an eCommerce site for vapes and juices.

I wanted some advice to see what platform I should use. To show you where my coding skills are at a project I am working on is available at

I've played around with Woocommerce. I'm intrigued by Magento.

I've also wondered about building an ecommerce site from scratch or with Laravel.

Thanks for your help, if I could make 1k a month I could pay expenses. What do I need to begin researching? Is this a foolish use of my money?
Here are the codes I have written to submit my shopping cart details to paypal.

        private $_api_context;

	public function __construct(){
             $paypal_conf = Config::get('paypal');		
             $this->_api_context = new ApiContext(new OAuthTokenCredential($paypal_conf['client_id'], $paypal_conf['secret']));
             $this->_api_context->setConfig($paypal_conf['settings']); //the problem is here

        $payer = new Payer();

       $items = new ItemList();
	     'price'=>$v['price'] * $v['quantity']

      $amount = new Amount();
      $transaction = new Transaction();
	->setDescription('Your transaction description');
      $redirect_urls = new RedirectUrls();
      $payment = new Payment();
	try {
	}catch (\PayPal\Exception\PPConnectionException $ex){
	}catch (Exception $ex) {
	$approvalUrl = 

Open in new window

I installed Laravel.

I created a virtual host on my computer with the hostname laravel.local.

When I installed Laravel I chose the name sample-application, and when it installed it, it  created a directory in my public directory that was called sample-application.

My question is really dumb, but because of apache mod rewrite, you won't have to move files around to display a page for laravel.local right?

I have a datatables table I am using to allow a person to resort the row order of the slides (see attached as example). In my mysql table I am using an additional column to set the row order of each row.
So essentially in mysql I have
id - primary auto increment
SlideOrder - I am using for the sequence
and a couple created/modified datetime etc.

table example
When the user drops a row into place the code I'm using is below to send to server ( I start getting sketchy here on in):

oTable.on( 'row-reorder', function ( e, diff, edit ) 
var result;
var sendloop = [];
	for ( var i=0, ien=diff.length ; i<ien ; i++ )
		var rowData = oTable.row( diff[i].node ).data();
		result = ''+diff[i].newData+','+diff[i].oldData+'';
	var jsonString = JSON.stringify(sendloop);
        type: "GET",
        url: "/dealboxx/ohs/admin/sort",
        data: {data : jsonString}, 
        cache: false

Open in new window

The result of which sends an ajax request and the data variable (when I drag row 1 below row 4 for example):

Had I dragged row 2 below row 3 initially I'd be sending:

Had I dragged row 3 in front of row 1:

When the data gets to my server (my wrong code) does this:
public function sortCourse(Request $request)
	$obj = json_decode($request->input('data'), true);
	foreach($obj as $row)
		$insertArray = explode(",",$row);
		$slidechange = DB::table('ohs_courses_content')
            ->where('id', $slidechange->id)
            ->update(['SlideOrder' => $insertArray[0]]);

Open in new window

Depending on what I initially dragged it may work (if I'm dragging down or up). Couple drags into it and its a mess.

So my logic etc is no doubt totally wrong.

any help would be very much appreciated as always.
I am running composer global require "laravel/installer"

I'm getting the following output

brian@brian-XPS-13:~$ composer global require "laravel/installer"
Changed current directory to /home/brian/.composer
Cannot create cache directory /home/brian/.composer/cache/repo/, or directory is not writable. Proceeding without cache
Cannot create cache directory /home/brian/.composer/cache/files/, or directory is not writable. Proceeding without cache
./composer.json is not writable.

Open in new window

I'm running Ubuntu 16.04.
I've been taking on the occasional client, undercharging for my hours to meet market rates, but I just discovered Wordpress and I realized I can have enough output (you know for the average site someone wants to have built) and I can charge extra for custom plugins or Laravel or other solutions that require something more than Wordpress.

After 2018 I would like to start taking on clients - I would like to have the following on my portfolio
-Ecommerce site for local business built with Woocommerce
-Ecommerce site built for another local business built with Woocommerce rewritten in Laravel, possibly with a new design possibly redone with wordpress - a social media site for people with prader willi syndrome written in Laravel - a streaming audio site for Umphrey's Mcgee written with Laravel and React

Would listing these sites be a good idea or a bad idea? Should I use Google Adwords? How much do I need to save up for advertising when I build a site advertising services?

I'm going to offer hosting and security. I'm studying Cyber Security and I don't know if I should put that.

I have Schizophrenia and Bipolar and it's a lot harder for me to communicate professionally that it is for most people. Presenting myself well will be a challenge, but I know that my work will be good. I have to work very hard at this, it doesn't come naturally to me, at least not since my diagnosis.

I want to create a streaming audio site for a band that allows taping. A site that it will be similar to is this one

How do I create a Streaming Audio site?

I'm not going to mess with Laravel right now, but I want to create a primitive Model View Controller for this site. Can you reference materials on how to build a MVC site?

Cloud Class® Course: Microsoft Office 2010
LVL 12
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

I am a Cyber Security major. I've done a lot of programming as a hobbyist, and when I got into Java (and later when I looked at Swift) I felt like I was experiencing some major breakthroughs with Object Oriented Programming and PHP.

I have Crohn's so I didn't even complete the first course which only went up to multidimensional arrays.

So now I need some guidance - do I work out of PHP Patterns Objects and Practice before learning a framework? That book covers Object Oriented Design as well as the concepts.

Should I do that or just move to Laravel and start learning that?

What would be best.

A huge question I have about object oriented frameworks are - can you add functionality that's not built into the framework into your application?

When designing a complex website do you want to use an existing framwork or build your own? If you use an existing one and functionality isn't built in how do you add functionality?
I have 5 tables namely product, category, price, inventory and image.

In my product table I have a foreign key column (category_id_fk) referencing to category table primary key column (id). In my product model I have the following function defined:

    public function price(){
		return $this->hasOne('App\Models\Price','product_id_fk');
    public function inventory(){
		return $this->hasOne('App\Models\Inventory','product_id_fk');
    public function image(){
		return $this->hasMany('App\Models\Image','product_id_fk');
    public function category(){
                return $this->belongsTo('App\Models\Category','id');

Open in new window

In my category model I have the following function defined:

      public function product(){
		return $this->hasMany('App\Models\Product','category_id_fk');

Open in new window

I have performed the following query:

$product = Product::with('price','inventory','image')->get();

Open in new window

The result is it return all records that exist in the product table and associated tables (price, inventory, image) which is correct.

However when I attempt to perform similar action by including the category table

$product = Product::with('category','price','inventory','image')->get();

Open in new window

The result is it return all records that exist in the product table and associated tables (price, inventory, image) but the category record is incorrect (either null or unrelated record).
Hey, guys!

Here's a snippet from a page called "user.class.php:"

 function updateDevices() {
        global $S;
        global $CN;
        $maxHistory = date('Y-m-d',strtotime("now - 2 weeks"));
        $R = new xajaxResponse();
        $fitBitCalls = array( '/1/user/-/body/weight/date/'.date('Y-m-d').'/'.$maxHistory.'.json',
        //See if this user any devices that have not been synced.
        $stmt = $CN->prepare("SELECT * 	FROM hraUserDevices  UD INNER JOIN hraUserDeviceTypes UT  ON UD.udtID = UT.udtID  WHERE usrID = ? AND (DATEDIFF(day,udFetchedLastDate,getdate()) IS NULL OR DATEDIFF(day,udFetchedLastDate,getdate()) >=1) AND (udUpdating IS NULL  OR udUpdating !=1 OR DATEDIFF(day,udFetchedLastDate,getdate()) >=2)");
        $devices = $stmt->fetchAll();
        $update = $CN->prepare("UPDATE  hraUserDevices SET udUpdating = ? WHERE udID = ? ");

Open in new window

The question I have is, "What is $CN?"

Obviously, it's a database connection. My problem is that it's not defined anywhere on the page, nor is EVER defined that I can see anywhere in the app.

You do, however, have this at the top of the same page:


	function __construct(PDO $conn) {
		if (!isset($conn))
			throw new Exception('User objects must be passed a PDO Connection object ($this->cn) upon construction');
		$this->cn = $conn;

Open in new window

Is there a convention that I'm missing? $CN is not equivalent to $cn, and yet throughout the entire app you see repeated references to $CN but I can't find anywhere that $CN is actually defined.

Any ideas?
Hi I want to update the DB when drag and drop.

I post here the question on SO and you can check all the code.

I will be really appreciated, i'm really stocked.

Have integrated social for facebook. It provides only name .But i require birthdate, first and last name, email and phone number.
Same for twitter and google

[token] => XXX
    [id] => 11111111111111
    [nickname] =>
    [name] => Treo Infotech
    [email] =>
    [avatar] =>
    [user] => Array
            [name] => Treo Infotech
            [id] => 11111111111111

    [firstname] =>
    [lastname] =>
    [avatar_original] =>
I'm trying to figure out what the correct way is to modify a date format before inserting when using Laravel 5.4.

I have:
public function store(){

        $trip = new Trip;
        $trip->tripName = request('tripName');
        $trip->departing = request('departing');
        $trip->returning = request('returning');

        return $trip;

        //return redirect('/home');

Open in new window

My database mySQL field in datetime, but the date that's passed in the variable is '07/17/2017 3:20 PM'.  How/where would I update that before insertion?
So I've installed Laravel with this tutorial:

I've then installed the authentication module using this tutorial:

All the pages are there, but when registering it complains about users table not existing in database which is true.  Have I missed a command to execute the migrations file to actually create this table?
The following data is returned from my laravel coded controller:

data object
[{"id":1,"name":"View","createdDate":"2017-07-12 14:54:05","lastUpdate":"2017-11-07 13:52:27"},{"id":2,"name":"Read","createdDate":"2017-07-12 14:54:05","lastUpdate":"2017-11-07 13:52:27"},{"id":3,"name":"Write","createdDate":"2017-11-07 13:52:27","lastUpdate":"2017-11-07 13:52:27"},{"id":4,"name":"Update","createdDate":"2017-11-07 13:52:27","lastUpdate":"2017-11-07 13:52:27"}]

Open in new window

try object
[{"id":1,"name":"Dashboard","createdDate":"2017-11-07 13:52:27","lastUpdate":"2017-11-07 13:52:27","permission":[{"id":1,"name":"View","createdDate":"2017-07-12 14:54:05","lastUpdate":"2017-11-07 13:52:27","pivot":{"module_id_fk":1,"permission_id_fk":1}},{"id":3,"name":"Write","createdDate":"2017-11-07 13:52:27","lastUpdate":"2017-11-07 13:52:27","pivot":{"module_id_fk":1,"permission_id_fk":3}}]},{"id":2,"name":"Employee","createdDate":"2017-11-07 13:52:27","lastUpdate":"2017-11-07 13:52:27","permission":[{"id":3,"name":"Write","createdDate":"2017-11-07 13:52:27","lastUpdate":"2017-11-07 13:52:27","pivot":{"module_id_fk":2,"permission_id_fk":3}}]},{"id":3,"name":"Report","createdDate":"2017-11-07 13:52:27","lastUpdate":"2017-11-07 13:52:27","permission":[]},{"id":4,"name":"Access Right","createdDate":"2017-11-07 13:52:27","lastUpdate":"2017-11-07 13:52:27","permission":[]}]

Open in new window

In my angularjs controller I have the following line of code:

	$ = function(a,b){
		$scope.tmp = [];	
		for(var outer in a[0]){
				for(var inner in b){
					if(b[inner].name === a[0][outer].name){
		return $scope.tmp;

	$scope.init = function(){
		$scope.dfperm = [];
		$scope.modperm = [];
		$scope.counter = 0;
			method: 'GET',
			url: "/api/v1/module/list"
		}).then(function successCallback(response){
			//$scope.module =;
			$array =;				
			angular.forEach($array, function(outer, key) {			
					angular.forEach(outer, function(outerItem, key){ 
						 var tmp = $$scope.dfperm,outerItem.permission);
		}, function errorCallback(response) {
			console.log('intention error',;

Open in new window

What I am attempting to do is to create a new permission object that has the status true or false.

As shown the data object contains a list of default permission.

The try object on the other hand shows that each module has permission. A module can have 0 or more than 1 permission.  

Now i'm trying to reconstruct the information so that each module has equal number of default permission but based on the try object conditioning (permission) is done to set the status either true or false.

However my code above doesn't do so. Rather a module with is set based on the try object conditioning (permission) and others are set with the default permission and status false.

Your help is kindly appreciated.
Hello Experts,

I would like to know if the is a authentication library within Laravel Framwork can support the following requirements? If so, what is it?

any immediate help is highly appreciated.

> - Application to prevent the re-use of the last 4 passwords.
> - After 5 failed login attempts to the application, further login attempts will remain locked until the affected account is unlocked by an administrator.
> - Password aging set to no more than 90 days, after that they should be reset.
> - Unused accounts should be disabled after one year of inactivity so that they may not be used to access the application.
> - After 5 failed login attempts to the application, further login attempts will be made impossible until the affected account is unlocked by an administrator.
Cloud Class® Course: CompTIA Cloud+
LVL 12
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

I want to know your opinion about site bayt, I want to ask developer framework laravel or other framework, what is the estimated time to realize a site like
Hi everybody.
So I finally decided to start with Laravel. I have followed this tut after having found not clear enough the official doc (since following that I didn't succeed accessing the example website):

With everything in place, I typed first
git clone Homestead

Open in new window

Then this
cd Homestead

Open in new window

I have edited the homestead.yaml:
ip: ""
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/.ssh/

    - ~/.ssh/id_rsa

    - map: m:/htdocs/LARAVEL_PROJ
      to: /home/vagrant/Code

    - map:
      to: /home/vagrant/Code/Laravel/public

    - homestead

# blackfire:
#     - id: foo
#       token: bar
#       client-id: foo
#       client-token: bar

# ports:
#     - send: 50000
#       to: 5000
#     - send: 7777
#       to: 777
#       protocol: udp

Open in new window

A first doubt: homestead.yaml should be .homestead directory but I get it in Homestead directory in my personal directory. Did something went wrong?
And edited the Windows hosts file.
I have created  the ssh key
ssh-keygen -t rsa -C “”

Open in new window

and I have logged in
homestead ssh

Open in new window

I have launched vagrant (with or without using the shorcut described in the tutorial)
Then I have created a laravel project
composer create-project --prefer-dist laravel/laravel Laravel

Open in new window

The folder Laravel is created ion the virtual machine but not on my hard disk: I can't get it!

Any idea?
I am attempting to apply multiple if condition along with the where condition for filtering purpose as below

		$employees = DB::table('employee')
								->select('id', 'name', 'age', 'gender', 'company')
								->where(function($query) use($name){
										return $query;

Open in new window

However only this condition applies


Open in new window

where else the other conditions are ignored.

Your help is kindly appreciated.
Here's the HTML that sets everything in motion:

 <li role="presentation"><a href="#summary" aria-controls="summary" role="tab" data-toggle="tab">Health Summary</a></li>

"#summary" - triggers this function:

    $('a[href="#summary"]').on('click', function(){
        }, 250);

HealthSummary.init - not sure what that means other than, "initialize." There's another script has this:

var HealthSummary = {
    initialized: false,
    init: function(){
        var self = this;
        if (self.initialized) {
            return true;
            var $this = $(this),
                id = $this.attr('data-id');
            if (id === '') {
                $this.html('<h3 class="text-center">Invalid health summary reference</h3>');
                return true;
            $this.html('<h3 class="text-center"><i class="fa fa-refresh fa-spin"></i> &nbsp;Loading Health Summary...<br /><small>(This should only take a few seconds.)</small></h3>');
            $.get('/health-summary/' + id, function(resp){
                if (resp.error) {
                    $this.html('<div class="alert alert-danger">' + resp.msg + '</div>');
                    return false;

Open in new window

Hi Experts, trying to install a Laravel application, and everything seems to be loading fine as intended, although when i try to install..any link is clicking through to localhost/appname instead of localhost:8888 ..not sure how to update this in laravel app, must be an .htdoc issue maybe...?  I am running on localhost.  Help much appreciated

				<tr ng-repeat="person in employee | orderBy:orderByField:reverseSort">
						 <div class="btn-toolbar" role="toolbar">
							<button class="btn" ng-click="viewEmployee("><span class="glyphicon glyphicon-eye-open"></button> 
							<button class="btn" ng-click="editEmployee("><span class="glyphicon glyphicon-pencil"></button> 
							<button class="btn" ng-click="deleteEmployee("><span class="glyphicon glyphicon-trash"></button>
                    <td align="center" colspan="6">  
                        <div class="pull-right">  
                             <pagination total-items="totalCount" ng-change="pageChanged()" items-per-page="pageSizeSelected" direction-links="true" ng-model="pageIndex" max-size="maxSize" class="pagination" boundary-links="true" rotate="false" num-pages="numPages"></pagination>  
                             <a class="btn btn-primary">Page: {{pageIndex}} / {{numPages}}</a>  

Open in new window


	scope.maxSize = 5;
	scope.totalCount = 0;
	scope.pageIndex = 1;
	scope.pageSizeSelected = 5;

        scope.init = function(){
			method: 'GET',
			url: "/api/v1/employee/list?pageIndex=" + scope.pageIndex + "&pageSize=" + scope.pageSizeSelected
              }).then(function successCallback(response){
			scope.totalCount =; 
                        scope.numPages =  Math.ceil(scope.totalCount / scope.pageSizeSelected);			
		        scope.employee =;

       scope.pageChanged = function(){

Open in new window

How do I handle pageIndex in laravel? Apart from that I am receiving an error: [orderBy:notarray] when returning in the following manner:

  public function lsAll(){
        $employee = Employee::paginate(5);
	return $employee; 

Open in new window



Laravel is a free, open-source PHP web application framework for the development of web applications following the model–view–controller (MVC) architectural pattern. Some of the features of Laravel are a modular packaging system with a dedicated dependency manager, different ways for accessing relational databases, utilities that aid in application deployment and maintenance, and its orientation toward syntactic sugar. Laravel is regarded as one of the most popular PHP frameworks.

Top Experts In