Where can I find html pages in a Laravel application? - php

I am currently learning Laravel. I had a pre-built script and I need to do some changes in it to make it usable... But as much I learnt from the web, I understood that the routes are specified in the Routes/web.php file.
But in the application I'm working on, the routes are defined in Routes/api.php file.
I even tried to find out the HTML pages in the Views folder but it only has the code for the tables which are there on the User Interface. All the controllers also return some data (like... return $data) in the end but no php or blade.php file is mentioned in any controller.
I need to find out the HTML pages so that I can change some components or elements from that website.
Please help me with this. Thanks!

there are two possibilities:1- the application is only used for backend purposes, which is why the developer used API instead of routes.
or the application is made by laravel/vuejs. again laravel for backend and vue js for frontend.
in the second case try to search for .vue files

You should look for blade templates. You can find them in resources/views
directory, these files have .blade.php extension.

Related

For a site built on CodeIgniter that is already deployed, is there a way to know which PHP file on the view the generate the HTML of each page?

I am currently working on site built by another developer on CodeIgniter. I do not have the GitHub repository since there is no way to reach the previous developer. All I have now is the project files stored in the file system of the host. I found the view folder of the project and see a bunch of PHP files on it. The codes of each PHP files look similar, I am having trouble knowing which PHP files generate which page.
My question is, on the browser, is there a way to know which PHP files generate the HTML of the page that I am currently viewing?
In CodeIgniter, Controllers are the routes generally. Look in the controllers directory. For example User controller with update method will result in /user/update route. Moreover, the developer might have specified custom routes too. You will have to check application/config/routes.php too. Once you will locate the correct controllers, you can find the views used by the related controllers (or routes). I hope this helps.
You cannot use the "view" files to quickly figure out what URL displays that file. It's entirely possible that any given "view" file is used on multiple pages. It's also quite likely that any given URL will use multiple "view" files.
You should instead examine the files under /application/controllers and look for lines of code making a call to $this->load->view('some_file_name_here'); There may or may not be a subdirectory as part of the file name - depends on how the original dev organized things.
The CodeIgniter documentation is excellent and is found HERE. Start with the General Topics. In particular, the following general topics (in the order shown) may be highly useful and help you make sense of what the other answers are talking about.
Controllers
Views
CodeIgniter URLs
URI Routing
Models
A read-through of the tutorial will be helpful too after checking out the above.
Use the Libraries section of the docs to get details on the various parts of the framework you're likely to run into in your explorations.

How to multi template with Laravel

You know wordpress template system. I'm writing a simple script with Laravel. I'm very beginner at Laravel. I need to more than one template and it must be selectable at admin panel.
I created subfolders at views doc like that:
project/resources/views
defaulttemplate
othertemplate
othertemplate2
I keep template's doc name in the database when one is selected. I want to run the site selected template.
How to I can do it?
Firstly, Wordpress has a million lines of code and it's open source. You have to observe their codes from github repo if you have ever never implemented an templating engine as same as Wordpress or any kind of equivalent applications. It's not best practice however you can simply create a new namespace for the view from the app container.
You can boot your namespace definition on AppServiceProvider
app("view")->addNamespace("theme",base_path('themes/'.DEFAULT_TEMPLATE_FOLDER_NAME));
Within this way, you can pass different folders as a view. you have to call your view files via themes:: namespace.
Let's assume you have a default folder in the themes folder as a default template and there is index.blade.php inside of it. You have to call it as a return view('themes::index') in the controller. If DEFAULT_TEMPLATE_FOLDER_NAME changed, the themes:: namespace will point to changed destination due to App Service Provider. It's a simplest version of wordpress-like templating. For the best case, you have to observe different kind of open source projects.

Laravel output source controller, model and view file path in all view source?

I've taken over management of a large complex site with multiple laravel installations of various ages. Some are in use some are only partially so for some routes (complex htaccess redirects abound).
I'm new to Laravel so this is a bit of a headache for me.
Is there an easy way to have laravel include the source path and filename of the controller, model and view it has used when rendering a view so I can find what files on the server are responsible for what 'pages' on the site?
TY
If you have a relative small site (i.e. a handfull of pages) you can visit each page with Laravel debugbar activated. In my office we use this for a while now and we are pretty positive about it. There is a special 'views' tab that enables you to see which views are included when you visit a certain page. It has some nice options, you can even view queries!
Example from our development environment with APP_DEBUG=true in the .env file:
In addition to the debugbar, you can also consider a package that shows route information for you by listing all routes that are called and showing the names of controllers, methods and request type in an other colour. We use Pretty routes since it is more convenient for us to read all 'routes' in the browser than in the terminal.
When starting from the app/ directory, the path of any of these classes is the same as the namespace they are in.
So if you have a model App\Models\User, this will be located in app/models/User.php.
As for the views, you start in the resources/views/ directory, replace dots in the view name by / and add .blade.php.
So, a view named website.index is located in resources/views/website/index.blade.php.
This is kind of an advanced answer that requires some Linux skills, but with the built in commando strace you can see which resources are opened: which php file, which database calls etc. This way you can analyze what is used when.
A very good tutorial can be found here:
https://hackernoon.com/debugging-a-php-application-with-strace-4d0ae59f880b
another great article on strace with PHP: https://ma.ttias.be/linux-application-script-debugging-with-strace/
I would also suggest to use all kind of filters and grep to filter the output to something meaningful.

vBulletin inside Laravel application

I recently finished my website's transition to Laravel and all that is left is the current forum software, vBulletin.
Right now, my website consists of various Blade files (all extending the main layout).
For the forum to work, I had to place all vBulletin files in a /forum directory inside /public and access them directly (having to add an exception in .htaccess file). So, by accessing them directly (by visiting example.com/public/forum/index.php for example), I am loosing all the Laravel functionality. But I also want to use some methods and controllers I have already defined in my Laravel site. Get the current user, his profile picture and other stuff.
Moreover, how can I use the Blade files outside of Laravel? For example, I would like to have a common header (which is already in its own header.blade.php file). How can I accomplish that instead of creating a new header.php file and have all blade syntax converted to html/php?
The question(s) above may be specific for vBulletin, but could be expanded to any application:
How do we use an external application inside Laravel, utilising Blade syntax and all the Classes / Controllers already implemented?
Thanks in advance,
Ilias

Generating nested resource with same directory structure in laravel 4

Sorry if I am asking a silly question here, but I have googled it a lot and couldn't find any satisfactory answer.
I have some experience with codeigniter and I am new to laravel.
I have just installed laravel and jeffrey way generator tool. I am first working on my back-end admin panel, so what I need is to create nested resources so it will map to domain.com/admin/SomeController
But while using php artisan generate:resource country --fields="name:string, status:boolean"
It is working fine. but generating controllers, models, views etc in respective root directory and controller name should also be changed to support nested controllers
I want to create all these in some meaningful directory structure
App/controllers/admin/AdminCountryController.php
App/models/admin/Country.php
App/views/admin/country/index.blade.php etc.
I also checked generator tool documentation but couldn't find these details.
So I want to know how can it be achieved using generator or I have to do it manually.
If I chosen wrong path please tell me as I am at very initial phase of my project and my application structure will depend on it.
You need to create first that directory. For example, you want a controller app/controller/admin/AdminController.php, first create the admin folder on app/controller, then you can do php artisan generate:controller admin/adminController.php.
I am not sure if this coulde be done using Resouce.
Also routing in laravel is different with routing in CI. CI depends on domain.com/controllerClass/method/args and laravel is different.

Categories