Jump to content

Laravel 5.4 Need help understanding basic functions

Hello!

I have just started to learn laravel and since I know some simpel php and some more fancy php I'm not that familiar to oop or the use of a framework.

 

So I want to create a function that when called echo's / returns etc my data out on a spesefic place on the page.

 

So basic php I would just create a function in my functions.inc.php file and call it where needed. How do I do this in Laravel? is this the use of classes?

Back-end developer, electronics "hacker"

Link to post
Share on other sites

First of all, Laravel is an MVC framework, so you need to learn the basics of that architectural pattern before attempting to make a web application with it. You also need some basic knowledge in OOP and databases. Most PHP Frameworks are pretty different than using vanilla PHP.

From salty to bath salty in 2.9 seconds

 

Link to post
Share on other sites

1 minute ago, Pandalf said:

First of all, Laravel is an MVC framework, so you need to learn the basics of that architectural pattern before attempting to make a web application with it. You also need some basic knowledge in OOP and databases. Most PHP Frameworks are pretty different than using vanilla PHP.

Currently trying to learn it, but experimenting with it helps alot.

Back-end developer, electronics "hacker"

Link to post
Share on other sites

Inside your controller is where you request your data from your model (database). You then pass this data to your view when you goto render it

It is inside your view where put the HTML for your data

 

Documentation for Laravel Views

https://laravel.com/docs/5.4/views

 

I recommend you watch Laravel From Scratch series from laracasts.com if are new Laravel

https://laracasts.com/series/laravel-from-scratch-2017

Link to post
Share on other sites

1 minute ago, Joveice said:

Currently trying to learn it, but experimenting with it helps alot.

There are many simple projects you can make like creating a blog, twitter clone, etc. You can find tutorials on Laracasts on the fundamentals of the framework and MVC. The documentation is also very well written.

From salty to bath salty in 2.9 seconds

 

Link to post
Share on other sites

Go watch laracasts, its one of the best ways to get into Laravel and get a OOP Mindset

Youtube a few videos to explain what MVC is till you get it.

 

You have to understand the Model View Controller setup to start with most of the frameworks, its a really well known concept and used by a huge amount of them.

Within an hour you already get the basics of it and see why people use it. Its just awesome.

Quote or mention me if not feel ignored 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×