Plants are particular to their environment. Some plants will grow well in shallow soil that does not drain well. But for most plants--particularly flowering plants and vegetables--the deeper and better draining the soil is, the better they will grow. So the deeper the planter box, the better the plants inside will grow.
If your available in-ground gardening space is slightly to severely limited, growing a garden in a planter box is still an option that can be successful, if you grow the right varieties. Some vegetable plants will not take well to a planter box. A rule of thumb is to provide plants with enough space to mature properly in all growing directions. The root growth, in many respects, is more important than the upward growth, because without healthy root growth, the plants will not grow. Build or purchase planter boxes and growing containers that are large and spacious. Fill them with the best, darkest, richest potting soil that you can find in your nursery. You can create your own potting soil mixture by combining peat moss, vermiculite or perlite, small composted wood chips and fertilizer. The mixture will be fluffy when it is added to the containers and will settle as you water the planter boxes. Fill the planter boxes quite full so the soil level will be satisfactory after all of the settling has occurred.
Different varieties of vegetable and flower seeds have to be planted in the ground at varying depths for best results. Similarly, the root balls of vegetable and flowering plant starts need to be planted at varying depths as well. Seeds and starts that require deeper planting depths should be planted in deeper planter boxes whereas seeds and starts that tolerate shallower planting depths can be planted in boxes that are quite shallow. A simple explanation is that some plants require the ability to spread their roots away from the main plant stem to a greater extent than others. For example, onion, radish, lettuce and spinach seeds can be planted at a depth of 1/2 inch, but English peas, Southern peas and pumpkins require planting depths of 3 to 5 inches. Potatoes require a planting depth of 3 to 6 inches. Corn and cucumbers like the depth of about 1 inch.
Basic wooden or plastic planter boxes that are easily and readily found in stores are 6 to 8 inches deep. These depths are ideal for growing aromatic or kitchen herbs of all kinds and flowering plants that grow easily, like petunias and impatiens. However, growing vegetables is a different situation. Vegetable plants need more room to root and grow. Seeds that are sown shallow (up to 1 inch deep) should have 12 to 15 inches of soil to grow into. Seeds that are sown deeper than 1 inch should have a minimum of 18 inches of soil beneath them to grow into. If a seed is planted 3 inches into the soil, the total soil thickness should be at least 21 inches. The seed packaging will tell you how deep the seeds need to be sown to be successful. Keep in mind that if planter boxes deep enough to grow what you would like to grow are not commercially available, you can build your own. Use redwood or cedar to build your own planter boxes.
Growing a garden is a lot of fun, but it is also a commitment and a lot of work. Between sowing, watering, weeding, fertilizing and harvesting, growing your own fresh produce will keep you busy for a few hours each week during the growing season. Do not waste your time trying to grow vegetables that will not do very well in containers. In addition to those mentioned above, also try growing radishes, green beans, eggplant, tomatoes, peppers and various herbs in containers. Herbs do especially well in containers and can be grown and used fresh all year long under the right conditions.