Ok I was working on a project using laravel 4. I never bothered setting up vhosts for pretty urls. I was just using localhost/myapp/public...
Everything was working fine. Now I have decided to set up vhosts. And I'm getting the following error when $user->save(); is called:
ReflectionException
Class confide.repository does not exist.
Auto-loading is not working why??
What am I forgetting??
Here is my vhost.conf set up:
<VirtualHost 127.0.0.6>
DocumentRoot "C:\xampp\htdocs\myapp\public"
ServerName myapp.dev
<Directory "C:\xampp\htdocs\myapp\public">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
</Directory>
</VirtualHost>
And my hosts setup:
127.0.0.6 myapp.dev
UPDATE: when I configure vhosts with: ServerName myapp instead of ServerName myapp.dev
It works great, however I want the .dev so that that I can use facebooks api.
Any help greatly appreciated.
I see you're on a Windows machine.
VHosts (Windows) related:
I'm using vhosts myself. Here's a copy of what I'm using in my WAMP Environment:
# Virtual Hosts Settings
NameVirtualHost *:80
<VirtualHost *:80>
ServerName appdomain.local
DocumentRoot "D:/Program Files/wamp/www/appname"
ErrorLog "D:/Program Files/wamp/www/appname/server_logs/errors.log"
TransferLog "D:/Program Files/wamp/www/appname/server_logs/access.log"
</VirtualHost>
…and in the hosts file I use:
127.0.0.1 appdomain.local
Try these settings and see if it works.
BTW.: Why are you using 127.0.0.6? Localhost is equal to 127.0.0.1... To use another IP some other settings need to be set / adjusted in Windows.
Laravel 4 related:
Have you checked the User model and composer.json file?
Did you follow the necessary installation instructions on https://github.com/Zizaco/confide#quick-start ?
Double check that.
Also look at this: https://github.com/Zizaco/confide/issues/9
About my App/Config/app.php config file:
I've setup a "production" and "local" app config. The main differences for the local version are:
- debug => true (production => false)
- url => THE_APP_LOCAL_DOMAIN (production => THE_APP_DOMAIN)
Everything else is set in the production config.
Providers example:
'providers' => array(
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider',
...,
),
Aliases example:
'aliases' => array(
'App' => 'Illuminate\Support\Facades\App',
'Carbon' => 'Carbon\Carbon',
...,
),
I always update the autoload (> composer dump-autoload) on:
namespace changes
composer.json edits
composer updates (e.g. after adding a new package from like packagist)
and config changes, just to be save
Also try the following commands: (don't forget to cd to the project directory first)
composer dump-autoload
php artisan dump-autoload
php artisan cache:clear
Related
After following the Laravel bootcamp that creates a small project called chirps, which works perfectly while using artisan on windows, when I try to access via apache in XAMPP, the inertia uris as defined below are not recognized in the browser
Route::get('/', function () {
return Inertia::render('Welcome', [
'canLogin' => Route::has('login'),
'canRegister' => Route::has('register'),
'laravelVersion' => Application::VERSION,
'phpVersion' => PHP_VERSION,
]);
});
This is config in my xampp/apache/conf/extras/httpd-vhosts.conf file.
<VirtualHost *:80>
DocumentRoot "{path}/public"
ServerName {projectName}.local
ServerAlias {projectName}.local
<Directory {path}/public>
AllowOverride none
Require all granted
</Directory>
</VirtualHost>
The app.blade.php file is loaded as expected but as soon as you try to go to login / register it does not recognise them when running via apache, but work fine when running under artisan. Anyone got any ideas?
I was testing a clean Laravel 6 installation to migrate an old Laravel project in one Ubuntu 18.04 environment, no used with PHP projects before.
After install PHP, Apache, Mysql... I test one PHP page OK.
I set the permissioins to 777 in /var/www/html/ subdirectories.
I cloned my old Laravel App to migrate and did one clean Laravel 6 installation.
First, I loaded the default welcome page in Laravel 6. After, I put some routes and views from the old project and tried to load some of then, but I had errors of type:
page don't found
I checked the settings of Apache and if mod_rewrite was available... finally, I run the old project OK, but my Laravel 6 is dissapeared. I can see it in the disk, but if load the http://localhost/laravel/ directory I can't see it.
Edited
Content of /etc/apache2/sites-available/000-default.conf:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
What i can suggest you to try is to define one Virtual Host for each project in this way:
Put this (with proper information) inside /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
DocumentRoot "/var/www/html/YOUR_LARAVEL_PROJECT_ROOT/public"
ServerName yourProjectDomain.dev
<Directory "/var/www/html/YOUR_LARAVEL_PROJECT_ROOT/public">
AllowOverride All
Options FollowSymLinks +Indexes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And inside /etc/hosts put
127.0.0.1 yourProjectDomain.dev
Then check the permission on /var/www/html and each subdirectory (you can use cd /var/www/html && sudo chmod -R 777 * to set everything as readable, writable and executable).
Then clear the cache of the project (delete all the files inside the bootstrap/cache folder).
Then you should be able to access that project just using yourProjectDomain.dev on every browser inside your pc.
Have the below config in vhosts. Its always returns 500 error when i run it through MAMP. Not sure what is wrong. Stopped mamp and ran it using valet. laravel website runs successfully. Permissions of bootstrap/cache and storage looks good. Error logs are empty cant debug and debug setting set to true in .env file. Only access log exists with 500 error. Below is the vhosts config that i have for MAMP. Other website in vhosts file work.
<VirtualHost *:80>
ServerName elearn.localhost
ServerAlias elearn.localhost
DocumentRoot "/Users/user1/code/elearn/public"
ErrorLog "/Users/user1/logs/elearn.localhost-error_log"
CustomLog "/Users/user1/logs/elearn.localhost-access_log" common
<Directory "/Users/user1/code/elearn/public">
DirectoryIndex index.php
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Order allow,deny
Allow from all
Require all granted
Satisfy Any
</Directory>
</VirtualHost>
What version of Laravel are you using, if it is 5.6 make sure you're running PHP at at least 7.1 in MAMP - fallen foul of that myself a couple of times?
Alrighty, checklist:
is MAMP running under your user?
make sure it's not permissions issues: commit, chmod 777 on project root, try again, if you still get 500 then it's ruled out
stop valet, restart mamp, just to be sure no services parts are conflicting
remove the vendor folder and composer install again, better be safe then sorry
lastly, add a dd() to any route and test it, if you see the dd, means it's not related to mamp, valet or laravel, probably config, driver or other issues.
I have started working in laravel and using lampp. I have watched many tutorials that use a vhost to make user-friendly url. I want to do it on Ubuntu 16.04.
Following tutorial is not working for me:
https://ourcodeworld.com/articles/read/302/how-to-setup-a-virtual-host-locally-with-xampp-in-ubuntu
<VirtualHost *:80>
DocumentRoot "/opt/lampp/htdocs/basicwebsite/public"
ServerName mywebsite.dev
</VirtualHost>
Setup a virtual host for a Laravel project
First, copy the default configuration file and rename it:
$sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/myVhost
open myVhost.conf file using this command:
$sudo nano /etc/apache2/sites-available/myVhost.conf
Add the directives:
assuming that the Laravel project is in /var/www/html/
ServerAdmin webmaster#localhost
serverName www.myAwesomeLink.com
DocumentRoot /var/www/html/laravel-app/public
<Directory /var/www/html/laravel-app>
AllowOverride All
</Directory>
so now the file will look something like this:
save and close.
Now add an entry in the hosts file:
$sudo nano /etc/hosts
add this line:
127.0.0.1 www.myAwesomeLink.com
save and close.
Enable site and the rewrite mode:
$sudo a2enmod rewrite
$sudo a2ensite myVhost.conf
Restart the server:
$sudo service apache2 restart
Serve the Laravel project:
open the project folder
php artisan serve
this will serve on port 8000 by default
you can also specify the port
php artisan serve --port=4200
Open the browser:
http://www.myAwesomeLink.com:8000
or any other specified port.
Source.
Its not working because the browsers have updated their security terms and policies including SSL certificates over .dev domains. just change your extension from .dev to something else like .localhost or .test.
<VirtualHost *:80>
DocumentRoot "/opt/lampp/htdocs/basicwebsite/public"
ServerName dev.mywebsite.test
</VirtualHost>
Also change the extension in /etc/hosts from .dev to .test.
127.0.0.1 dev.mywebsite.test
Also keep in mind to restart the service to load the new added virtual host i.e: restart the Apache server
Hope it helps.
I think you also need to add a host in /etc/hosts. Open the hosts file and add this line:
127.0.0.1 mywebsite.dev
You will need to restart server after this.
1.Create new file under this path /etc/apache2/sites-available/myweb.conf
2.Copy the following to the file
# Indexes + Directory Root.
DirectoryIndex index.php
DocumentRoot /var/www/html/mywebsite/public
ServerName dev.mywebsite.test
<Directory "/var/www/html/mywebsite/public">
Options All
AllowOverride All
Allow from all
</Directory>
3.Run "sudo a2ensite myweb.conf"
4.Add this line "Listen 80" to file "/etc/apache2/ports.conf"
5.Restart apache server
I am trying to install ZendFramework latest version on XAMPP. I added XAMPP directory on environment variables.XAMPP server works properly on 8080 port. After that I installed git and ran below commands respectively:
git clone git://github.com/zendframework/ZendSkeletonApplication.git zendtest
cd zendtest
php composer.phar self-update
php composer.phar install
and I didn't get any error. After that I added these lines to C:\xampp\apache\conf\extra\http-vhosts.conf file:
<VirtualHost *:8080>
<DocumentRoot "C:/xampp/htdocs/zendtest/public"
ServerName www.zendtest.loc zendtest.loc
ServerAlias zendtest.loc
<Directory "C:/xampp/htdocs/zendtest/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:8080>
<DocumentRoot "C:\xampp\htdocs">
ServerName localhost
</VirtualHost>
And added this line to hosts file:
127.0.0.1:8080 zendtest.loc localhost
With these adjusments apache server on XAMPP doesn't work. When I press the start button for apache server, XAMPP application doesn't respond. Whenever I restore http-vhosts.conf file, XAMPP works properly. What am I doing wrong?
I am able to notice a typo error in the httpd-vhosts.conf file. Please replace this line <DocumentRoot "C:/xampp/htdocs/zendtest/public" with DocumentRoot "C:/xampp/htdocs/zendtest/public" (remove the preceding angular bracket).
I checked this in my local box Xampp was refusing to start but works fine after removing the angular bracket.