When Sāriputta says that good friendship is the whole of the spiritual life, the Buddha agrees, explaining that good friendship is the basis for the development of the Noble Eightfold Path.

Sāriputta sutta - Sāriputta

At Sāvatthi.

Then, Venerable Sāriputta approached the Blessed One, paid homage to him, and sat down to one side. Sitting to one side, Venerable Sāriputta said to the Blessed One:

"Venerable Sir, the whole of this spiritual life is this good friendship, good companionship, good association."

"Excellent, excellent, Sāriputta. The whole of this spiritual life is this good friendship, good companionship, good association. It can be expected, Sāriputta, that a bhikkhu with good friends, companions, and associates will develop and extensively cultivate the Noble Eightfold Path. And how, Sāriputta, does a bhikkhu with good friends, companions, and associates develop and extensively cultivate the Noble Eightfold Path?

Here, Sāriputta, a bhikkhu develops right view dependent on seclusion, supported by dispassion, based on ending, culminating in complete relinquishment; similarly he develops right intention, right speech, right action, right livelihood, right effort, right mindfulness, and right collectedness, dependent on seclusion, supported by dispassion, based on ending, culminating in complete relinquishment. Thus indeed, Sāriputta, a bhikkhu with good friends, companions, and associates develops and cultivates the Noble Eightfold Path extensively.

By the following method too, Sāriputta, it may be understood how the entire spiritual life is good friendship, good companionship, good association: by relying on me as a good friend, Sāriputta, beings who are subject to birth are freed from birth; beings who are subject to aging are freed from aging; beings who are subject to death are freed from death; beings who are subject to sorrow, lamentation, pain, displeasure, and despair are freed from sorrow, lamentation, pain, displeasure, and despair. It is by this method, Sāriputta, that it may be understood how the entire spiritual life is good friendship, good companionship, good association."