Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Implementing php programing to a html form without using slim or composer ?

Hello , I'ce created a form in html , I've done the css , and I want it to submit to a database . After I saw the course : Building Websites with PHP , I've kinda got scared , because I have to implement composer and slim to use php , and create a new index.php file , in other words my work until now is equal to 0 , Is it posible for me to make the same thing as in that course , without using composer & slim , What I mean is , can I use only php programing language to make it happen or it's a necessity to instal composer and slim to make a form validate and submit to a database ? P.S. : I don't want to go on the rout that was presented in the course , is there a simple cleaner way ?

4 Answers

Kevin Korte
Kevin Korte
28,149 Points

Agreed, Slim is a php framework, and composer is a php dependency manager. You don't need to use either tool; although they are quite popular, they are also overkill for this small project.

You can create your own db connection, write your own validation (I find some help for basic php validations online), and write to your db. Check out php's PDO class. That'll help you get the job done.

http://php.net/manual/en/book.pdo.php

Julian Aramburu
Julian Aramburu
11,368 Points

Great answer Kevin! I recomend using PDO too Andrei so check it out!

The whole slim and composer thing, really turned me off. It was just confusing, and I didnt really help me improve PHP knowledge.

I think Treehouse, should do something seperate, more thorough on a framework and dependency manager, instead giving someone who is trying to learn actual PHP a headache.

Kevin Korte
Kevin Korte
28,149 Points

Hey Aman, what was confusing, and how good is your understanding of PHP? I don't mean this in a rude way at all. I understand that frameworks can be confusing because there is a lot of things "under the hood" so to speak.

You can turn using frameworks like Slim into a great learning too. Since Slim is just an opinionated scaffold written in php, you can start to reverse engineer Slim. If there is a part you don't understand, you can break it down to it's core php parts, and read about each part on the php docs site.

Composer is just awesome once you learn it, but there is a learning curve, just like with Git.

Aman Mender, I agree with you that it looks like the Slim/Composer course is a good starting place. I don't think it is. The track I cited (or just the PHP courses in it) are where I think you should start. Treehouse is going to implement some changes that will allow moderators to communicate with the staff more efficiently. I will certainly raise the name of the Slim course to them. Slim 3 is also getting ready to be released, so the course may have to be redone in the near future anyway. There are some significant changes if I understand the new version correctly.

Julian Aramburu
Julian Aramburu
11,368 Points

Hi mate! Of course you can :D! Slim and Composer are just tools to help you out but it doesn't mean you can't do it everything by yourself! Coding your own validation for your form and push the submitted data to your DB is totally doable so... start coding! :D Also doing it by yourself it's not only a great way to practice but also to understand better how other people code works or why is it coded the way it's coded.

Cheers and Keep Coding!

Wow guys , I am so happy to be a member of this awesome comunity , thanks both of you guys , you are awesome . Thanks again for everything !

I started with this PHP track. It takes you through from the beginning and is great. I don't think it is in the track, but there is a course where you take the shirts for mike web site you build in the track and implement a database using PDO. I strongly recommend that track and course. Depending on your experience and comfort with PHP and web design in general, you can skip to what interests you. But if you are not very experienced, take all the courses.

That track does not use Slim or Composer.

Does my html and css will fade when I use php ? , I've used javascript for validating the form and make it unvalid untill the form is fully completed ... so can I still use php without modifying what I've done so far ? I don't want to throw it away , I've put a lot of work in the designe and the layout . Waiting for an answer

Neither fade. PHP will likely show you ways to refactor your code so you don't repeat yourself as much with things like your navigation, but you can run pure html in a php file if you choose to. It is just generally a bad practice. CSS is completely independent of PHP. PHP is a server side language, so it decides what html is sent for display. The CSS works on whatever HTML is sent to the client.