Reputation: 93
I am facing a strange issue with Larave 5.2 routing. Please find below details.
1) I have created HomeController with index() in it and set my route for "/". It was working fine.
2)After that I have renamed HomeController.php to Readme_couchbasenotes.php and created fresh HomeController. Since then my route is not working properly. Whenever I give HomeController@index it is looking for index in Readme_couchbasenotes.php.
routes.php:
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
//Route::auth();
Route::get('/','HomeController@index');
(Fresh) HomeController:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
class HomeController extends Controller {
public function index() {
return "Hello";
}
}
Readme_couchbasenotes.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use CouchbaseCluster;
class HomeController_copy extends Controller {
public function index() {
/**
* Different ways of doing CRUD operations on couchbase
*/
//---------------------------------------------------------
/**
* To Create PRIMARY INDEX for data buckets
*/
// $query = 'CREATE PRIMARY INDEX `laravel-sample-primary-index` ON `laravel` USING VIEW;';
// $res = \DB::connection()->bucket('laravel')->select($query);
// var_dump($res);die;
//--------------------------------------------------------------
/**
* To Select set of records from data buckets
*/
// Using \DB:: facades
//
// $query = 'SELECT * FROM system:indexes WHERE name="beer-sample-primary-index";';
// $res = \DB::connection('couchbase')->table('laravel')->where('name', 'Sri Harsha')->get();
// $doc = Json_encode($res, True);
// var_dump($doc);die;
//
//
//
/**
* Using OOP concepts with inbuilt couchbase methods
*/
echo "<br>After Retrieve<br>";
echo "------------------<br>";
$Cluster = New CouchbaseCluster('http://127.0.0.1:8091');
$bucket = $Cluster->OpenBucket('laravel');
Try {
$result = $bucket->get('test2');
} Catch (Exception $e) {
Echo "CouchbaseException:" . $e->getMessage() . " \n";
}
$doc = $result->value;
echo $doc->_id . "<br>" . $doc->name . "<br>";
/**
* To Update records into data buckets
*/
echo "<br> After Update<br>";
echo "------------------<br>";
$doc->name = 'Stranger';
$u_result = $bucket->replace('test2', $doc);
$doc2 = $bucket->get('test2')->value;
echo $doc2->_id . "<br>" . $doc2->name . "<br>";
/**
* To Insert records to data buckets
*/
echo "<br> After Create.New Record Details<br>";
echo "----------------------------------------<br>";
$data = [
'_id' => 'test3_insert',
'name' => 'Sri Harsha 3 insert'
];
$bucket->Insert('test3', $data);
$doc3= $bucket->get('test3')->value;
echo $doc3->_id . "<br>" . $doc3->name . "<br>";
/**
* To Delete records from data buckets
*/
echo "<br>After Delete<br>";
echo "------------------<br>";
$bucket->Remove('test1');
echo "<br>test1 has been deleted.";
//
}
}
3) I even tried
php artisan cache:clear
php artisan clear-compiled
php artisan route:clear
Still it is looking for Readme_couchbasenotes.php whenever HomeController is mentioned.
srturaka@srturaka-pc:~/Desktop/work/dev.laravel5.2.com/public_html$ php artisan route:list
[ErrorException]
include(/home/srturaka/Desktop/work/dev.laravel5.2.com/public_html/app/Http/Controllers/Readme_couchbasenotes.php): failed to open stream:
No such file or directory
And one thing, this issue is only for HomeController because I renamed it, others are working fine which are new controllers.
Please suggest, if I miss anything. Thanks
Upvotes: 0
Views: 631
Reputation: 1619
Sometimes these kinds of issues arise due to the cache. So try running:
composer dump-autoload
.
If this doesnot work try using:
sudo composer dump-autoload
. (Since you are using ubuntu)
Running php artisan config:clear
or
php artisan cache:clear
might help as well
Upvotes: 1
Reputation: 572
change class name HomeController to Readme_couchbasenotes
namespace App\Http\Controllers;
use Illuminate\Http\Request; use App\Http\Requests;
class HomeController extends Controller {
public function index() {
return "Hello";
}
}
Readme_couchbasenotes.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use CouchbaseCluster;
class Readme_couchbasenotes extends Controller {
-----
}
Upvotes: 0