Posts

Showing posts with the label Laravel

Laravel Composer main Command

Laravel Composer main Command These are the main composer command which is necessary when you install first time a Laravel Project. composer self-update - It will self update the composer composer update - It will update the all library or packages for laravel project composer dump-autoload - This will update the autoload, If any file is update or class added composer dumpautoload - This is same function as above

app/storage/meta/services.json: failed to open stream: Permission denied - Laravel 4

If you are getting this error on your laravel 4 installation so put the steps as i mention below Error is like this in laravel 4 ErrorException file_put_contents(/var/www/vhosts/folder/app/storage/meta/services.json): failed to open stream: Permission denied  That means permission is not granted to write for meta folder so you need to run these command on your server from your root folder Step 1: Come to your root folder var/www/vhosts/yousite_folder/ Step 2: Run this command first find app/storage -type d -exec chmod 777 {} \; Step 3: Run this command now find app/storage -type f -exec chmod 777 {} \; These command will chmod all directories and files in app/storage to 777.  Done!! Now you can refresh your page and working fine. If this post help you please submit a comment in post to inspire me :)

How to write MySql Query in laravel?

I will show a simple query in laravel where you can easily understand that how query works in laravel 4. $limit = 5; $value= Bank::where('isactive','=','yes')->where('money','>',0)->whereNotNull('account')->whereNull('credit')->take($limit)->orderBy('id', 'DESC')->get(); This query act like as query below select * from Bank where money>0 amd account!=null and credit='' order by id desc limit 0,5. This is the representation that how laravel query works i added here where condition with 3 different ways and limti and order by for this query This query will work for both Database MYSQL MongoDB

How to get XML response output in laravel?

How to get XML response output in laravel? or How to create XML response output in laravel? or Most of developers use header function to create xml file but this does not work header('Content-type: application/xml'); $output  = "<?xml version='1.0' encoding='UTF-8'?>"; here i will tell you that how can you show or save XML response output in laravel you have an array where you have data Here is an example that how can you create xml file response in laravel suppose you have an array which have twitter data //Preapre our output for xml data $output  = "<?xml version='1.0' encoding='UTF-8'?>"; $output .= "\n<twitterfeed>\n"; $j=0; foreach($twitterinfo as $row){ $j++; $output .= "<feed>\n"; $output .= "<id>" . $j . "</id>\n"; $output .= "<twitter_id>" . $row['twitter_id'] . "</twitter_id>\n"

No hint path defined for [folder] in laravel?

No hint path defined for [folder] in laravel. There could be several reasone for this error in laravel. But most of time it works like a charm to solve this probelm - No hint path defined for If you will check your view file which you have include in your controller or routes. then  you will find that on view file you have some code like this in your view/file.php @extends('Folder::layouts.default') Or @include('Folder::includes.header') to pass the view in templates so where folder is mention you can change the folder  path where your file is located.

How to get the input value after validation failed in laravel 4?

You can get the particular input field after validation failed in laravel 4. simple use the old method with Input class to get the last inserted value of input box. $getvalue = Input::old("fieldName");

How to create a table via Artisan in laravel?

Create a table in database via Artisan in laravel Step1: First you need to go on your root directory Step2: php artisan migrate:make create_users_table paste this code into your command interface Step3: Check the file named 2014_mm_dd_114554_create_users_table.php in your Root\app\database\migrations folder Step4: There will be two method Up and Down paste this Schema in this method  public function up()     {         //         Schema::create('users', function($table)         {             $table->increments('id');             $table->string('email')->unique();             $table->string('name');             $table->timestamps();         });     }     /**      * Reverse the migrations.      *      * @return void      */     public function down()     {         //         Schema::drop('users');     } Step5: Run this command on your root directory php artisan migrate You  can check the database there will a

How to set flash message in laravel?

Set flash message in laravel You need to add this code in your controller Session::flash('loginerror', "Your Email-id or Password does not match."); return Redirect::to('login'); Now you need to add this code in your view section @if (Session::has('loginerror'))    <h2>{{ Session::get('loginerror') }}</h2> @endif

How to pass parameter in routes using controller in laravel?

You can just pass the parameter like this in your routes.php file Route::get('company/{name}', array('as' => 'companydetails', 'uses' => 'PublicareaController@companydetails')); And you need to add your controller this code like this: public function companydetails($name)     {         echo $name;         die; }

How to Load external library in Laravel-4?

How to Load external library in Laravel-4? I was really confused that how to load library in laravel 4 and after search a lot on sites i got a nice and easy way to use external class inside a library. Here are some steps that how to do it easily:- 1) First create a folder inside app it should be like this  app/libraries/your app folder/twitter.php   twitter.php must contain a class and function.  2) Open composer.json from your root folder "autoload": {         "classmap": [             "app/commands",             "app/controllers",             "app/models",             "app/database/migrations",             "app/database/seeds",             "app/tests/TestCase.php",             "app/libraries"                    ]     },  add this line "app/libraries"   as shown above 3)  Now open your CMD as administrator Run command like: composer dump-autoload example: C:/wamp/w