Photosynthesis requires 3 things: sunlight, water and CO2. Light provides the energy to carry out all metabolic reactions; CO2 provides the material to form sugars such as glucose and water provides oxygen that will be released as a waste product into the environment.
In conclusion, photosynthesis only serves to produce sugars that will be used to produce energy (glucose) or to build structures (cellulose).
Energy is obtained through glycolysis in the mitochondria. Photosynthesis does not produce energy.