i installed Vagrant on my macOS with the Parallels provider.
I created a new project with the command laravel new blog.
When i opened the site everything works fine. Then i want to add an auth with these commands: php artisan make:auth php artisan migrate
The first command works fine but the second produces errors:
PHP Warning: Unexpected character in input: ' in /home/vagrant/blog/routes/web.php on line 17
I figured out that the problem is between the vagrant box "homestead" and macOS. Because after i turned off the sync between homestead and macOS and reinstalled the whole project it worked fine. So can you tell me where the problem is? Is it the charset?
This is what my web.php looks like (i made no changes):
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Route::get('/home', 'HomeController#index')->name('home');
It happened to me also. Enabling NFS solved my problem. Not sure what is the cause.
Homestead.yaml
folders:
- map: ~/code
to: /home/vagrant/code
type: "nfs"
If somebody still running into this problem,the solution for me was:
Exit from vagrant ,and once out of it, reload the vagrant VM and enter again to your project folder and run:
composer dump-autoload
php artisan migrate
After that ,im not getting the error and the column in my case is being created in the DB table
Related
The title sums up my issue. I'm deploying to shared hosting by uploading my files (except mylaravelproject/public/ to the root directory, and the contents of mylaravelproject/public/ to public_html/.
I've already tried the following:
Configuring index.php to point to the correct folder in root
Running composer install and npm install in the relevant directory
php artisan key:generate
php artisan cache:clear and php artisan config:clear
composer dump-autoload
Configuring .env and changing the relevant fields: APP_URL and database related ones
I'm still met with a white screen and an HTTP 500 error. What should I do?
Whoops! I was able to solve it on my own somehow. Thanks to everyone who replied still.
For anyone having similar issues:
Start by adding the following to the top of index.php:
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
Turns out hpanel / hostinger's directory structure is weird, and public_html/ from the file manager is actually a shortcut to a folder not directly under root. Here's what it actually looks like:
/
| - domains
| - yourdomainname.com
| - public_html
| - index.php
So unlike most guides out there, relevant directories under index.php need to be changed to something like __DIR__.'/../../../laravelinrootname/storage/framework/maintenance.php'
Enable debugger to know the issue
inside Config/App.php change
'debug' => env('APP_DEBUG', false)
to
'debug' => env('APP_DEBUG', true)
& in .env make APP_DEBUG= true
APP_ENV=local
APP_DEBUG=true
I am new Laravel, and this is my first project, I got this project which already has some pages and I have to add an admin login page, so I created adminlogin.blade.php file in the resource folder, and make controller using command
php artisan make:controller AdminController
then in AdminController, I have created a function
public function viewAdminLogin() {
return "Hello From admin login controller";//not working
return view('adminlogin');//this one also not working, i have tried both return statement one by one.
}
Then in routes/web.php, I added this code
<?php
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/pricing', 'CalculatorController#index');
Route::post('/quote', 'CalculatorController#quote');
Route::get('/', 'Controller#index');
// pages view
Route::get('/howitworks', 'Controller#howitworks');
Route::get('/US-Domestic-Shipping-Services', 'Controller#USDomesticShippingServices');
Route::get('/International-Shipping-Services', 'Controller#InternationalShippingServices');
Route::get('/Ship-Packages', 'Controller#ShipPackages');
Route::get('/Ship-Envelopes', 'Controller#ShipEnvelopes');
Route::get('/Student-Shipping', 'Controller#StudentShipping');
Route::get('/about', 'Controller#About');
Route::get('/FAQs', 'Controller#FAQs');
Route::get('/Prohibited-Items', 'Controller#ProhibitedItems');
Route::get('/Track-Shipment', 'Controller#TrackShipment');
Route::get('/contact', 'Controller#Contact']);
Route::get('/adminlogin', 'AdminController#viewAdminLogin');
I have also run these series of command after importing this project:
composer install
php artisan key:generate
php artisan migrate
php artisan db:seed
php artisan serve
after running http://127.0.0.1:8000/adminlogin it is returning a 404 page, Please help Thank you for reading.
Run the following clear commands:
//---Regenerates the list of all classes that need to be included in the project
composer dump-autoload;
//---Remove Routes Cache
php artisan route:clear;
//---Flush the application cache
php artisan cache:clear;
//---Remove the configuration cache file
php artisan config:cache;
php artisan config:clear;
And after that restart your server
php artisan serve
If your route has been cached, then you need to clear the cache data :
php artisan route:clear
If you want to cache it, then simply run :
php artisan route:cache
Here is the official documentation about route caching
I'm new on laravel , I didn't write any code yet but when I open my project it gives me this error , anyone can help me to solve it ?
[
Just try http://localhost:8000 since it seems like you already started development server in your local machine using php artisan serve while you were on your project root via terminal.
Or you can try from begining:
Go to your project root from terminal / cmd
Run php artisan serve
Now try http://localhost:8000 which is equivalent to http://localhost/laravel/public , considering laravel is your project folder name.
I' upload the project from localhost to my dedicated server and after so many problems, finally some pages works domain.com | domain.com/home | domain.com/allsites etc..
But now, the routes "domain.com/site/create"
"domain.com/site/ID/manage", "domain.com/site/ID/edit" not found, i get this error, why?
InvalidArgumentException in FileViewFinder.php line 137: View [Site.create] not found.
in FileViewFinder.php line 137 at
FileViewFinder->findInPaths('Site.create',
array('/....../resources/views')) in FileViewFinder.php line 79 at
FileViewFinder->find('Site.create') in Factory.php line 151
I try artisan comands: cache:clear, route:clear, config:clear, config:cache and nothings works, i don't know where is the problem!
On localhost it works perfectly
also multiple times its found that config cache being problem. Use following commands to finetune them.
php artisan config:cache
php artisan config:clear
If your local OS is different from your production server OS you might be running into a case-sensitive issue and the file is not being found. make sure your files names are EXACTLY the same, case and all. This can happen especially if one environment is Mac and the other is Linux.
If the issue is not fixed, please go through the following link. It may help you
Laravel 5 - View [home] not found
Laravel 5.1 View not found
Laravel 5 InvalidArgumentException in FileViewFinder.php line 137: View [.admin] not found
I had same issue but cause was different. For me the problem was permissions on errors folder. In particular the folder was not executable.
To resolve on linux:
$ chmod +x ../views/errors
Try one of these commands:
php artisan dump-autoload or composer dump-autoload
check you passed argument are in database fields or not!
$mailData = array(
'type' => 'email_subscription',
'user_mail' => $obj->email_id
);
Mail::to($request->input('email'))->send(new SendMail($mailData));
I'm using Laravel 5 and when I am running php artisan route:list, it always gives me an error of SQLSTATE[HY000] [1045] Access denied for user 'homestead'#'localhost' (using password: YES). This shouldn't be because my application will not be connecting to any database since it will be a static website.
I tried removing the variables on the .env file:
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
Just still gives me errors. It seems like it is still connecting to the database wherein it shouldn't make any database connection.
I was experiencing the same issues when I upgraded my Laravel installer from v1.1 to v1.2.
It appears that the routes.php file by default is adding the Authentication route:
Route::controllers([
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
]);
This causes to display an error message to what you were describing:
$ php artisan route:list
[PDOException]
SQLSTATE[28000] [1045] Access denied for user 'forge'#'localhost' (using password: NO)
I resolved this by removing the scaffolding included within Laravel by executing the following command:
$ php artisan fresh
Or by simply deleting the Auth route within the file itself.
You should now be able to run: php artisan route:list
Hope this helps!
This might be the problem of localhost. Do check your WAMP, MAMP, LAMP and XAMP MySql server if you are using any of them.
This have solve my problem:
It looks like artisan might be working in the wrong environment. Run "php artisan tinker", then "App::environment();" to see which environment Artisan is running in. If it is something other than production, you need to create a folder with that environments name within your app/config folder, and put a copy of the "database.php" file in it.
After That if you are not doing any DB related task it will not access DB.
I found answer here
Alternatively You can run following command to resolve this issue:
php artisan migrate:install --env="local"
After this run you command:
php artisan route:list
Enjoy.