I'm a beginner to laravel. I had a laravel project, in which I have to fix some CSS. I have installed laravel 5.2 successfully and started laravel development server. But when I visit the site, it can't find any of the CSS, Image or JS file.
Failed to load resource: http://127.0.0.1:8000/public/frontend/css/stylesheet.css
However if I just remove public/, to make URL like this by editing page source in browser, it works fine.
http://127.0.0.1:8000/frontend/css/stylesheet.css
Also, if I open the site without using starting laravel development server, it can find all resources but the URL routing doesn't work. Then it couldn't find the web pages except the home page.
I know this project runs perfectly on hosting server, but I can't set it up on my local machine.
I'm using Windows and WAMP Server. Please help me to setup the project.
To avoid this kind of problem use asset() helper to build CSS, JS and images links:
<link rel="stylesheet" href="{{ asset('css/style.css') }}">
Also, web server should be pointed to a public directory inside Laravel project roo.
Related
I want run my Angular front-end client within Laravale index.html.
I have mange to set up and build both projects. When I open Laravel Client at port 8000 it says it can not find any of the .js files (404 error).
I read something about base href to be set properly but I can not figure it out.
Any ideas ?
Create a new project with Angular Cli in some directory of Laravel project and then build the frontend project and copy the “dist” files in the public directory and in Laravel routes “/” render the index.html and that's it.
For more info you can follow this tutorial. I hope it would help you.
I'm using Laravel with intellij and whenever I run my project this is what it looks like in the web browser
I'm not sure if I set up Laravel correctly on intellij. I set it up for XAMPP because I thought that was the problem however my pages are still looking like the image above.
probably it's not laravel problem. Maybe is better to setup local server in right way. You can try:
php artisan serve
under laravel root dir and then open in http://localhost:8000 in browser
Those icons are trying to use php built in server and may not be configured to match your laravel project. I get the same thing as you with localhost:63342 when clicking web browser preview icons in my Symfony project. I just configured phpStorm preview icons to load based on my web server root.
When using laravel, trying to load your blade views directly will most likely run into issues. Your request is not being mapped to a route/controller for it to be properly handled. For my symfony project and after configuring phpStorm, i get sent to app.dev/app/Resources/views/test.php, which is not a valid route (proves point of previous sentence). You will most likely get the same issue in your laravel project.
You can configure your phpStorm preview icons to load to your localhost:8000 / app.dev or whatever you may have set your app host to.
Follow the below phpStorm articles if you want to mess with this some more.
https://www.jetbrains.com/help/phpstorm/2016.3/working-with-web-servers-copying-files.html
https://www.jetbrains.com/help/phpstorm/2016.3/creating-a-local-server-configuration.html
I've created a web application using Symfony 3. In the development environment, I always use Symfony's built-in server and just use the command "php bin/console server:run". The app can then be accessed via "localhost:8000".
I've also defined routes using annotations in Controllers such as "/", "/about" etc. These pages can be accessed via "localhost:8000/" and "localhost:8000/about". Other links on the page that point to routes like "/contact" or "/users/1" also work perfectly. They will link to "localhost:8000/contact" and "localhost:8000/users/1".
Now, I move my application to the production server. On the production server, Apache2 is installed and some other people have developed Symfony applications on it. Their apps can be accessed via url like "example.com/apps/app1/web/app_dev.php" and the links on their apps have been pre-appended with "example.com/apps/app1/web/app_dev.php" automatically. So when the user clicks a button that links to "/contact", the link will direct to "example.com/apps/app1/web/app_dev.php/contact".
Now, when I move my application named "app2" under the "example.com/apps/" directory, I can visit "example.com/apps/app2/web/app_dev.php" without any configuration and see my homepage perfectly. Apache can automatically pick up my code. However all the links on the homepage will direct to "example.com/contact" instead of "example.com/apps/app2/web/app_dev.php/contact".
Can anyone help me with this? I'm pretty new with Symfony and Apache.
Or perhaps I've done the migration from dev to production environment in a totally wrong way? Any new ideas or proper way to move Symfony3 application to production server?
Thanks a lot!
Do you have apache configured correctly? You may need to have a virtualhost configuration added to the server. You can find out about it on the Symfony site for the specifics.
I finally solved the issue. I should use href="{{ path('about') }}" instead of href="/about" in all twig templates. Thanks everybody!
I tried to move my laravel 4.1 project from my office system to my personal laptop and I have tried it using various methods:
1) git and bitbucket
2) zipped whole folder and copy
3) using composer install/update on laptop directory to update my dependencies
Neither of the above has worked for me.
I do see my landing page but on clicking any link, it shows:
Not Found
The requested URL was not found on this server.
Seems like some routing error but I do see my index page. Thanks in advance.
It must be a problem with the url rewriting on your system . make sure you fix your htaccess/nginx directives . and also make sure configurations such as mod_rewrite is enabled .
In future try using laravel homestead , so that you have consistent environment across various workstations. It's the recommended way of working using laravel.
I created an app with Laravel and angular. On development The app works good in php artisan serve in localhost:8000.
if i copied the project folder and paste in www of lamp or wamp then i need to use localhost/projectname/public. To load the css and js i use <base href="/projectname/public/"> in my main html.
But my urls and angular templates still miss the projectname/public. if I click a url it goes to localhost\url. How to prefix url in angular? or is there another way to work this out?
There are 2 ways to fix this.
First is laravel homestead. This is perfect for laravel projects. for more information about homestead go here
The other option is to setup a virtual host on your wamp server. For more info about this go here