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.
Related
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
So I have a question relating running a Laravel application alongside another application and how I can achieve getting past (or utilising) Laravel's routing to run them in harmony.
So assume we have the following file structure
Public_html
/public - holding Laravel files
/billing - holding WHMCS
How can I get around Laravel not finding routes and throwing an exception? Could I deploy the Laravel app to find the index of public in the root folder instead?
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 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
Hey so I am completely new to Laravel 4 and have some basic questions regarding my first time installation that I was unable to find answers to anywhere else on-line. I am planning of hosting a standard website with a fully dynamic web back end and a RESTful API using the framework. I have been following this installation guide and am essentially at the part where I type laravel new projectDir and it creates a new instance of Laravel in the provided directory.
Now my main public directory is public_html, is it recommended to install Laravel 4 directly into that directory. So is something like laravel new public_html recommended? I have found many other questions here that seem to suggest that this is not the safest solution. Should I make a separate directory inside public_html, is it necessary for what I am planning on doing with laravel?
Also, I would like to keep my URL's as neat as possible and would like them primarily to be www.domain-name.com/pagename for the website. Will creating a directory inside of public_html disable me from doing so?
Lastly I had some issues with routing my URL's when I tried to install a different framework on this server. Are there any server/Apache settings that would impact how URL's are routed with laravel that I should disable/enable before I install Laravel into a directory?
you would not put the base Laravel folder in public_html.
In a Laravel directory structure, which gets created when you do the laravel new command, there is a directory called public. This is what you map your web root to. So on my vps, I have a folder called /var/site/mywebapp which was created by the command:
laravel new mywebapp
In nginx (which I much prefer over Apache), I map my server root to:
/var/sites/mywebapp/public
In the public folder is an index.php that Laravel uses to run your whole app/site. The rest of the framework is outside of the web root and is not accessible by HTTP.
As for your URL issues, consult the documentation for how to properly configure your mod_rewrite (assuming Apache).
Also, Dayle Rees, a prominent member of the Laravel community (and core contributor), has a github of sample web server configs here:
https://github.com/daylerees/laravel-website-configs
When you install Laravel it will create a public folder, along with app, bootstrap and vendor folders.
The public folder is essentially your public_html folder where you want your host/apache to point to when viewing the root of your website. So mydomain.com should land directly within the public folder.
You can rename the public folder to public_html just be sure to also update bootstrap/paths.php paths value
'public' => __DIR__.'/../public',
// change to
'public' => __DIR__.'/../public_html',
Laravel will create a .htaccess file for you, which will grab URLs and redirect them to public/index.php which will process Laravel accordingly.
So to answer the question, you install Laravel one folder back from public_html and then you can rename public to public_html if your host requires.