Laravel 4 installation on server not working - laravel-4

Hello I have installed laravel 4 on my server, the installation was done from cpanel , I get the default welcome message of Laravel on this link http://www.mysite/laravel/public
I added a controller and a view and I tried to run the url for that new controller and I get a Error 404 - Not Found
The document you are looking for may have been removed or re-named. Please contact the web site owner for further assistance.
This is what I did after laravel was installed :
TestController.php
<?php
class TestController extends BaseController {
public function index()
{
return View::make('index');
}
}
routes.php
Route::get('/Test', function()
{
return View::make('index');
});
views/index.php
<h1>Test</h1>
am I doing something worng?
here is my folder structure :

I had a similar problem when deployed my project on a host the first time.
You should put all the content of your public folder in the pre-existing public or public_html folder and the whole app folder in the root folder of the server.
Then you change app/config/app.php to tell the new path of app to laravel, and change your .htaccess file to point the document root to the new public folder.
This worked for me, if you need additional details, ask.

Related

Path for images for Laravel project from cpanel

I have a problem with displaying pictures in View for my project in Laravel..destination path in my application where the photos were saved is: public_path (/ images) but recently I put the project on the server in cpanel, and to get rid of / public from the url, I used a google article, and I made a folder called laravel outside the public_html folder, in which I keep the application files and in public_html I keep only the files that were in the public folder of the application. In View I display the pictures as follows: "{{asset ('images /'. $ Img-> file_name)}}" .. Only it is no longer displayed. Pictures are saved but no longer displayed. I mention that it is saved in the Laravel folder which is outside the public_html folder..and I think that public / images was created automatically there..I would like to know if anyone has faced such a thing and what is the solution. thank you
I solved the problem like this:
In AppServiceProvider in register() I put this code:
$this->app->bind('path.public', function () {
return base_path('../public_html');
});
and now I have public_html/images and there my images are saved..and the rest of myy app, outside public_html folder in a different folder named laravel_project
In Laravel 8, I solved it adding this to the /app/Providers/AppServiceProvider.php in register method:
public function register()
{
$this->app->bind('path.public', function () {
return base_path('../public_html');
});
}
But in order to create the symlink from the "php artisan storage:link" command, I also had to add this code to /bootstrap/app.php, just after the last singleton:
$app->bind('path.public', function () {
return base_path("../public_html");
});
Finally I used this code to get the image that will be sent to my blade template:
$image=Storage::disk('public')->url('path_to_image');

Laravel deployed to shared hosting not displaying image

I deployed a laravel app to shared hosting (hostinger). Everything is working fine except the images which are not showing up.
I have created a symlink of my storage folder with my public_html folder. Files uploaded enters the public folder but when I link the images they still do not show up.
I have created a symlink to the public_html since I cannot access the public folder. I need help on this please
I need the image to be displayed on the browser
In default Laravel deployment the symlink is created in public folder as storage and links to ../storage/app/public.
In order to debug your problem, please have a look at the developer tools of your browser to find out whether it is a 404 or 403 problem (or even another).
Please check for correct permissions. Otherwise you may change the physical storage path to something inside the public folder. This avoids the requirement to create a symlink. Keep in mind to protect non-public storage via .htaccess for example.
You have to the path to your public assets directory if it is not public directory in the root folder. In your case, the public assets directory is public_html. So please bind the path to it from the root folder.
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* #return void
*/
public function register()
{
if (App::environment('prod')) {
$this->app->bind('path.public', function() {
return base_path('../../public_html');
});
}
}
}
had the same problem, remember to run 'php artisan config:cache' as per Laravel Deployment guidelines.
Running the command creates a general configuration file
in app/bootstrap/cache/config.php with all settings including directories and links that you should update

Returns 404 even if MVC files are setup properly in Codeigniter

My code igniter project is returning 404 whenever I use method that I created in controllers. I have it running on Mac OS Mojave on Apache2.
There might be configuration or setting that I missed.
The codeigniter page works fine when opening http://localhost/myproject where I see the welcome page.
I have a 404 problem when I start using the new controller class. To make it simple, I created below "Pages.php" controller file inside application/controllers folder:
<?php
class Pages extends CI_Controller {
public function view()
{
echo "running the view method";
}
}
I expected the page to display "running the view method"
but the result is a 404 page at http://localhost/myproject/view or http://localhost/myproject/index.php/view.
it works by adding below in route.php
$route['(:any)'] = 'pages/$1';

Laravel Route to Standalone WebApp

I am trying to build a portal in Laravel to serve some other, standalone web apps (not built in Laravel), but I am struggling to find out how to route to these apps if I want to place them outside the public folder.
In the past, I would use (temporary) symlinks for this kind of things, but I was wondering if Laravel provides another solution.
So, I have a folder:
module
module/index.php
module/js/whatever
module/css/whatever
module/img/whatever
and I want a route /modules/1 to link to index.php in the module-folder in such a way that the resources in this folder (js/css/img) are also accessible.
Any suggestions?
You can include other PHP files with require_once.
web.php
Route::any('/webapp/{assets?}', 'WebAppController#index');
WebAppController
class WebAppController {
public function index(Request $request) {
require_once '../module/index.php';
if ($request->assets) {
// check from session if user is logged in
// require asset as well
// (or download them https://laravel.com/docs/5.5/responses#file-downloads)
}
}
}
http://php.net/manual/en/function.require-once.php

Problem with basepath or apppath in CodeIgniter with SSL - looking in wrong place?

I have an app in the main directory of my site at www.mysite.com and another development version of the same site in a subdomain http://dev.mysite.com. Both the public_html and dev_html directories are on the same level - ie. they are both contained within the same directory. When I access the dev site via http:// everything is fine - it displays as it should. However, once the user authenticates and the site switched to https:// the dev application starts looking at the controllers and views in the public_html directory. I have no idea why - all links, forms and redirects are relative so they shouldn't jump to the controllers and views in the public_html folder. Also, the URL continues to show https://dev.mysite.com/
Does anyone have any idea where I should start to look? The config.php file has all the correct values. Also, here is the auth_controller which extends the base controller.
class Auth_Controller extends My_Controller {
Public $auth;
Private $CI;
Public $auth_levels = Array();
function __construct()
{
parent::__construct();
$this->data['user_realname'] = $this->db_session->userdata('user_realname');
$this->auth = $this->db_session->userdata('userAuthLevel');
$this->CI =& get_instance();
$this->auth_levels = $this->CI->config->item('auth_levels');
if ($_SERVER['SERVER_PORT'] != 443)
{
redirect(uri_string(), 'location', TRUE);
}
}
}
Any help on how to debug this would be appreciated.
CodeIgniter version is 1.71.
Have you checked your virtual host configuration in the web server config? This can seems obvious, but in apache's virtualserver you need to specify the port, and ssl is falling into the default-ssl config.

Resources