Laravel and Angular url prefix issue with apache - php

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

Related

How to run AngularJS project with Laravel

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.

Having trouble configuring Laravel

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

Zend Skeleton framework not displaying using Php

I am working through the ZEND Skeleton installation described here
I am running it on an Apache server (in my home network) on Ubuntu 16.10
When I switched off the server yesterday the installation was working correctly, and displaying the expected Zend pages, as per the documentation.
To clarify - I need to know why the previously working installation on Apache has stopped rendering the pages in Php
I bookmarked these links in my browser. When I booted the server this morning and went to those links I get the result shown in the image below:-
Local browser URL (192.168.1.201/zendtest1/)
Zend Skeleton index
It appears that in switching off and on the machine the Zend installation has stopped accessing Php to render out the page in the browser.
Does anyone have any experience of this, or any suggestion as to what may have occurred?
The document root of a ZF2/ZF3 project is public, so you should use one of the strategies exposed in the quick start to either:
set the proper document root on your server
use the php development server
use vagrant and a VM
use docker
You could also access the address with typing /public at the end, that will probably not work at some point for your assets though. Then you will need to fix your basepath.

Importing existing laravel project couldn't find CSS files

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.

Problems when moving Symfony3 app from dev to production server

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!

Categories