How to transfer music on my iphone to my mac?

I just bought a new MacBook Pro today. And I want to transfer all my music from my iPhone onto the computer. It's the only place I have all my music. How do I get it to transfer?

Connect it to iTunes and sync the purchases already on the device. If you didn't buy your music, then you can't.

Use the apple cable

You'll probably end up doing it through iCloud. Here is all the information you're going to need on that: